* [wide-int 5/5] Add dump () method for gdb debugging
@ 2014-04-25 13:58 Richard Sandiford
2014-04-26 2:50 ` Kenneth Zadeck
0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2014-04-25 13:58 UTC (permalink / raw)
To: gcc-patches; +Cc: zadeck, mikestump
This patch adds a dump () method so that it's easier to read the
contents of the various wide-int types in gdb. I've deliberately not
done any extension for "small_prec" cases because I think here
we want to see the raw values as much as possible.
Tested on x86_64-linux-gnu. OK to install?
Thanks,
Richard
Index: gcc/wide-int.cc
===================================================================
--- gcc/wide-int.cc 2014-04-25 14:48:03.263213403 +0100
+++ gcc/wide-int.cc 2014-04-25 14:48:25.186333842 +0100
@@ -2130,3 +2130,9 @@ wi::only_sign_bit_p (const wide_int_ref
void gt_ggc_mx (widest_int *) { }
void gt_pch_nx (widest_int *, void (*) (void *, void *), void *) { }
void gt_pch_nx (widest_int *) { }
+
+template void wide_int::dump () const;
+template void generic_wide_int <wide_int_ref_storage <false> >::dump () const;
+template void generic_wide_int <wide_int_ref_storage <true> >::dump () const;
+template void offset_int::dump () const;
+template void widest_int::dump () const;
Index: gcc/wide-int.h
===================================================================
--- gcc/wide-int.h 2014-04-25 14:34:54.823652619 +0100
+++ gcc/wide-int.h 2014-04-25 14:48:06.218229309 +0100
@@ -709,6 +709,9 @@ #define INCDEC_OPERATOR(OP, DELTA) \
#undef ASSIGNMENT_OPERATOR
#undef INCDEC_OPERATOR
+ /* Debugging functions. */
+ void dump () const;
+
static const bool is_sign_extended
= wi::int_traits <generic_wide_int <storage> >::is_sign_extended;
};
@@ -859,6 +862,23 @@ generic_wide_int <storage>::operator = (
return *this;
}
+/* Dump the contents of the integer to stderr, for debugging. */
+template <typename storage>
+void
+generic_wide_int <storage>::dump () const
+{
+ unsigned int len = this->get_len ();
+ const HOST_WIDE_INT *val = this->get_val ();
+ unsigned int precision = this->get_precision ();
+ fprintf (stderr, "[");
+ if (len * HOST_BITS_PER_WIDE_INT < precision)
+ fprintf (stderr, "...,");
+ for (unsigned int i = 0; i < len - 1; ++i)
+ fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ",", val[len - 1 - i]);
+ fprintf (stderr, HOST_WIDE_INT_PRINT_HEX "], precision = %d\n",
+ val[0], precision);
+}
+
namespace wi
{
template <>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [wide-int 5/5] Add dump () method for gdb debugging
2014-04-25 13:58 [wide-int 5/5] Add dump () method for gdb debugging Richard Sandiford
@ 2014-04-26 2:50 ` Kenneth Zadeck
2014-04-26 8:38 ` Richard Sandiford
0 siblings, 1 reply; 4+ messages in thread
From: Kenneth Zadeck @ 2014-04-26 2:50 UTC (permalink / raw)
To: gcc-patches, mikestump, rdsandiford
don't you think that it would be easier to understand the number if you
printed it largest index first, as in the routines in wide-int-print.cc?
kenny
On 04/25/2014 09:58 AM, Richard Sandiford wrote:
> This patch adds a dump () method so that it's easier to read the
> contents of the various wide-int types in gdb. I've deliberately not
> done any extension for "small_prec" cases because I think here
> we want to see the raw values as much as possible.
>
> Tested on x86_64-linux-gnu. OK to install?
>
> Thanks,
> Richard
>
>
> Index: gcc/wide-int.cc
> ===================================================================
> --- gcc/wide-int.cc 2014-04-25 14:48:03.263213403 +0100
> +++ gcc/wide-int.cc 2014-04-25 14:48:25.186333842 +0100
> @@ -2130,3 +2130,9 @@ wi::only_sign_bit_p (const wide_int_ref
> void gt_ggc_mx (widest_int *) { }
> void gt_pch_nx (widest_int *, void (*) (void *, void *), void *) { }
> void gt_pch_nx (widest_int *) { }
> +
> +template void wide_int::dump () const;
> +template void generic_wide_int <wide_int_ref_storage <false> >::dump () const;
> +template void generic_wide_int <wide_int_ref_storage <true> >::dump () const;
> +template void offset_int::dump () const;
> +template void widest_int::dump () const;
> Index: gcc/wide-int.h
> ===================================================================
> --- gcc/wide-int.h 2014-04-25 14:34:54.823652619 +0100
> +++ gcc/wide-int.h 2014-04-25 14:48:06.218229309 +0100
> @@ -709,6 +709,9 @@ #define INCDEC_OPERATOR(OP, DELTA) \
> #undef ASSIGNMENT_OPERATOR
> #undef INCDEC_OPERATOR
>
> + /* Debugging functions. */
> + void dump () const;
> +
> static const bool is_sign_extended
> = wi::int_traits <generic_wide_int <storage> >::is_sign_extended;
> };
> @@ -859,6 +862,23 @@ generic_wide_int <storage>::operator = (
> return *this;
> }
>
> +/* Dump the contents of the integer to stderr, for debugging. */
> +template <typename storage>
> +void
> +generic_wide_int <storage>::dump () const
> +{
> + unsigned int len = this->get_len ();
> + const HOST_WIDE_INT *val = this->get_val ();
> + unsigned int precision = this->get_precision ();
> + fprintf (stderr, "[");
> + if (len * HOST_BITS_PER_WIDE_INT < precision)
> + fprintf (stderr, "...,");
> + for (unsigned int i = 0; i < len - 1; ++i)
> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ",", val[len - 1 - i]);
> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX "], precision = %d\n",
> + val[0], precision);
> +}
> +
> namespace wi
> {
> template <>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [wide-int 5/5] Add dump () method for gdb debugging
2014-04-26 2:50 ` Kenneth Zadeck
@ 2014-04-26 8:38 ` Richard Sandiford
2014-04-26 12:18 ` Kenneth Zadeck
0 siblings, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2014-04-26 8:38 UTC (permalink / raw)
To: Kenneth Zadeck; +Cc: gcc-patches, mikestump
Kenneth Zadeck <zadeck@naturalbridge.com> writes:
> don't you think that it would be easier to understand the number if you
> printed it largest index first, as in the routines in wide-int-print.cc?
Yeah, that's what the patch does. E.g. (for 32-bit HWI):
[...,0x3,0x80000000]
is 7 << 31.
Thanks,
Richard
>
> kenny
> On 04/25/2014 09:58 AM, Richard Sandiford wrote:
>> This patch adds a dump () method so that it's easier to read the
>> contents of the various wide-int types in gdb. I've deliberately not
>> done any extension for "small_prec" cases because I think here
>> we want to see the raw values as much as possible.
>>
>> Tested on x86_64-linux-gnu. OK to install?
>>
>> Thanks,
>> Richard
>>
>>
>> Index: gcc/wide-int.cc
>> ===================================================================
>> --- gcc/wide-int.cc 2014-04-25 14:48:03.263213403 +0100
>> +++ gcc/wide-int.cc 2014-04-25 14:48:25.186333842 +0100
>> @@ -2130,3 +2130,9 @@ wi::only_sign_bit_p (const wide_int_ref
>> void gt_ggc_mx (widest_int *) { }
>> void gt_pch_nx (widest_int *, void (*) (void *, void *), void *) { }
>> void gt_pch_nx (widest_int *) { }
>> +
>> +template void wide_int::dump () const;
>> +template void generic_wide_int <wide_int_ref_storage <false> >::dump () const;
>> +template void generic_wide_int <wide_int_ref_storage <true> >::dump () const;
>> +template void offset_int::dump () const;
>> +template void widest_int::dump () const;
>> Index: gcc/wide-int.h
>> ===================================================================
>> --- gcc/wide-int.h 2014-04-25 14:34:54.823652619 +0100
>> +++ gcc/wide-int.h 2014-04-25 14:48:06.218229309 +0100
>> @@ -709,6 +709,9 @@ #define INCDEC_OPERATOR(OP, DELTA) \
>> #undef ASSIGNMENT_OPERATOR
>> #undef INCDEC_OPERATOR
>>
>> + /* Debugging functions. */
>> + void dump () const;
>> +
>> static const bool is_sign_extended
>> = wi::int_traits <generic_wide_int <storage> >::is_sign_extended;
>> };
>> @@ -859,6 +862,23 @@ generic_wide_int <storage>::operator = (
>> return *this;
>> }
>>
>> +/* Dump the contents of the integer to stderr, for debugging. */
>> +template <typename storage>
>> +void
>> +generic_wide_int <storage>::dump () const
>> +{
>> + unsigned int len = this->get_len ();
>> + const HOST_WIDE_INT *val = this->get_val ();
>> + unsigned int precision = this->get_precision ();
>> + fprintf (stderr, "[");
>> + if (len * HOST_BITS_PER_WIDE_INT < precision)
>> + fprintf (stderr, "...,");
>> + for (unsigned int i = 0; i < len - 1; ++i)
>> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ",", val[len - 1 - i]);
>> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX "], precision = %d\n",
>> + val[0], precision);
>> +}
>> +
>> namespace wi
>> {
>> template <>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [wide-int 5/5] Add dump () method for gdb debugging
2014-04-26 8:38 ` Richard Sandiford
@ 2014-04-26 12:18 ` Kenneth Zadeck
0 siblings, 0 replies; 4+ messages in thread
From: Kenneth Zadeck @ 2014-04-26 12:18 UTC (permalink / raw)
To: gcc-patches, mikestump, rdsandiford
i am sorry, i missed the fact that the loop counts up but you were
reversing the order in the indexes.
kenny
On 04/26/2014 04:26 AM, Richard Sandiford wrote:
> Kenneth Zadeck <zadeck@naturalbridge.com> writes:
>> don't you think that it would be easier to understand the number if you
>> printed it largest index first, as in the routines in wide-int-print.cc?
> Yeah, that's what the patch does. E.g. (for 32-bit HWI):
>
> [...,0x3,0x80000000]
>
> is 7 << 31.
>
> Thanks,
> Richard
>
>> kenny
>> On 04/25/2014 09:58 AM, Richard Sandiford wrote:
>>> This patch adds a dump () method so that it's easier to read the
>>> contents of the various wide-int types in gdb. I've deliberately not
>>> done any extension for "small_prec" cases because I think here
>>> we want to see the raw values as much as possible.
>>>
>>> Tested on x86_64-linux-gnu. OK to install?
>>>
>>> Thanks,
>>> Richard
>>>
>>>
>>> Index: gcc/wide-int.cc
>>> ===================================================================
>>> --- gcc/wide-int.cc 2014-04-25 14:48:03.263213403 +0100
>>> +++ gcc/wide-int.cc 2014-04-25 14:48:25.186333842 +0100
>>> @@ -2130,3 +2130,9 @@ wi::only_sign_bit_p (const wide_int_ref
>>> void gt_ggc_mx (widest_int *) { }
>>> void gt_pch_nx (widest_int *, void (*) (void *, void *), void *) { }
>>> void gt_pch_nx (widest_int *) { }
>>> +
>>> +template void wide_int::dump () const;
>>> +template void generic_wide_int <wide_int_ref_storage <false> >::dump () const;
>>> +template void generic_wide_int <wide_int_ref_storage <true> >::dump () const;
>>> +template void offset_int::dump () const;
>>> +template void widest_int::dump () const;
>>> Index: gcc/wide-int.h
>>> ===================================================================
>>> --- gcc/wide-int.h 2014-04-25 14:34:54.823652619 +0100
>>> +++ gcc/wide-int.h 2014-04-25 14:48:06.218229309 +0100
>>> @@ -709,6 +709,9 @@ #define INCDEC_OPERATOR(OP, DELTA) \
>>> #undef ASSIGNMENT_OPERATOR
>>> #undef INCDEC_OPERATOR
>>>
>>> + /* Debugging functions. */
>>> + void dump () const;
>>> +
>>> static const bool is_sign_extended
>>> = wi::int_traits <generic_wide_int <storage> >::is_sign_extended;
>>> };
>>> @@ -859,6 +862,23 @@ generic_wide_int <storage>::operator = (
>>> return *this;
>>> }
>>>
>>> +/* Dump the contents of the integer to stderr, for debugging. */
>>> +template <typename storage>
>>> +void
>>> +generic_wide_int <storage>::dump () const
>>> +{
>>> + unsigned int len = this->get_len ();
>>> + const HOST_WIDE_INT *val = this->get_val ();
>>> + unsigned int precision = this->get_precision ();
>>> + fprintf (stderr, "[");
>>> + if (len * HOST_BITS_PER_WIDE_INT < precision)
>>> + fprintf (stderr, "...,");
>>> + for (unsigned int i = 0; i < len - 1; ++i)
>>> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ",", val[len - 1 - i]);
>>> + fprintf (stderr, HOST_WIDE_INT_PRINT_HEX "], precision = %d\n",
>>> + val[0], precision);
>>> +}
>>> +
>>> namespace wi
>>> {
>>> template <>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-26 12:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25 13:58 [wide-int 5/5] Add dump () method for gdb debugging Richard Sandiford
2014-04-26 2:50 ` Kenneth Zadeck
2014-04-26 8:38 ` Richard Sandiford
2014-04-26 12:18 ` Kenneth Zadeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).