Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: Pedro Alves <palves@redhat.com>,
	GDB Patches <gdb-patches@sourceware.org>
Subject: RE: "set record instruction-history" ?
Date: Mon, 25 Mar 2013 17:25:00 -0000	[thread overview]
Message-ID: <A78C989F6D9628469189715575E55B2307BA7E4F@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <51507403.6030208@redhat.com>

> -----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


  reply	other threads:[~2013-03-25 16:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 17:23 Pedro Alves
2013-03-25 17:25 ` Metzger, Markus T [this message]
2013-03-25 19:55   ` Pedro Alves
2013-03-26 16:21     ` Metzger, Markus T
2013-03-26 16:53       ` Pedro Alves
2013-03-26 16:58         ` Metzger, Markus T
2013-03-26 19:35           ` Pedro Alves
2013-03-27 10:03             ` Metzger, Markus T
2013-03-27 11:23               ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A78C989F6D9628469189715575E55B2307BA7E4F@IRSMSX102.ger.corp.intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox