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]

RE: "set record instruction-history" ?


> -----Original Message-----
> From: Pedro Alves [mailto:palves@redhat.com]
> Sent: Monday, March 25, 2013 4:58 PM
> To: GDB Patches; Metzger, Markus T
> Subject: "set record instruction-history" ?
> 
> Hi Markus,
> 
> I'm going through all "uinteger" commands in the tree, and
> finding several cases of commands that actually shouldn't
> be "uinteger", but "zuinteger".
> 
> "record instruction-history"'s implementation looks odd enough that
> I don't understand what's going on.  The docs don't mention anything
> about 0 being special or meaning "unlimited", but I take it that's
> the intent?
> 
> What's the intent of:
> 
>   /* The "record instruction-history" command.  */
> 
>   static void
>   cmd_record_insn_history (char *arg, int from_tty)
>   {
>     int flags, size;
> 
>     require_record_target ();
> 
>     flags = get_insn_history_modifiers (&arg);
> 
>     /* We use a signed size to also indicate the direction.  Make sure that
>        unlimited remains unlimited.  */
>     size = (int) record_insn_history_size;
>     if (size < 0)
>       size = INT_MAX;
> 
> these last three lines here, though?

This odd code makes sure that very large values don't wrap around to very small
values when we convert from unsigned int to signed it.  This would change the
meaning of those values.

I do not expect the trace to be near as big as INT_MAX so INT_MAX and anything
bigger than INT_MAX essentially means unlimited.


> One can't set this option to negative values:
> 
>   (gdb) set record instruction-history-size -2
>   integer -2 out of range
> 
> The fact that it maps all negatives to INT_MAX is odd,
> and needing to set the option to high-enough unsigned 32-bit
> integers that trigger that bit of code looks quite
> non-user-friendly, even if it didn't always map to INT_MAX:
> 
>   (gdb) set record instruction-history-size 0xffffff00
>   (gdb) show record instruction-history-size
>   Number of instructions to print in "record instruction-history" is 4294967040.
> 
> (and exposes 32-bitness to the user, that I'd rather not)

Given that the trace can't get bigger than INT_MAX, the user would
still get what he asked for - all the trace.  I don't really expect such high
numbers.  I'd rather expect users to set it to unlimited if they get above
100 or so.

How should I correct it?

Regards,
Markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052


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