* [PATCH] ctf-reader: Fix length in dynamic array definition
@ 2021-11-26 23:17 Guillermo E. Martinez
2021-11-27 18:03 ` Jose E. Marchesi
2021-11-28 1:56 ` [PATCH v2] " Guillermo E. Martinez
0 siblings, 2 replies; 7+ messages in thread
From: Guillermo E. Martinez @ 2021-11-26 23:17 UTC (permalink / raw)
To: libabigail
Hello libabigail team,
This patch fix the `length' property of `subrange' node when
we define a dynamic length array,
Please let me know your comments,
Thanks in advanced!,
Guillermo
Defining an array type with dynamic length, node `subrange'
in the abixml file doesn't write the accurate `length'
property `infinite', instead `1' is written:
<subrange length='1' .../>
So, member function `array_type_def::subrange_type::is_infinite'
is set when `upper_bound' value is equal to `0' or UINT64_MAX.
* src/abg-ctf-reader.cc (process_ctf_array_type):
set subrange_type::is_infinite when `upper_bound' value
is equal to `0' or UINT64_MAX.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
src/abg-ctf-reader.cc | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index c571d825..687686d9 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -472,6 +472,7 @@ process_ctf_array_type(read_context *ctxt,
{
array_type_def_sptr result;
ctf_arinfo_t ctf_ainfo;
+ bool is_infinite = false;
/* First, get the information about the CTF array. */
if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
@@ -507,6 +508,19 @@ process_ctf_array_type(read_context *ctxt,
lower_bound.set_unsigned(0); /* CTF supports C only. */
upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
+ if (upper_bound.get_unsigned_value() == 0)
+ {
+ is_infinite = true;
+ }
+
+ if (UINT64_MAX == upper_bound.get_unsigned_value())
+ {
+ // If the upper_bound size is the max of the integer value, then
+ // it most certainly means infinite size.
+ is_infinite = true;
+ upper_bound.set_unsigned(0);
+ }
+
subrange.reset(new array_type_def::subrange_type(ctxt->ir_env,
"",
lower_bound,
@@ -517,6 +531,12 @@ process_ctf_array_type(read_context *ctxt,
if (!subrange)
return result;
+ subrange->is_infinite(is_infinite);
+ ABG_ASSERT(subrange->is_infinite()
+ || (subrange->get_length() ==
+ (uint64_t) (subrange->get_upper_bound()
+ - subrange->get_lower_bound() + 1)));
+
add_decl_to_scope(subrange, tunit->get_global_scope());
canonicalize(subrange);
subranges.push_back(subrange);
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ctf-reader: Fix length in dynamic array definition
2021-11-26 23:17 [PATCH] ctf-reader: Fix length in dynamic array definition Guillermo E. Martinez
@ 2021-11-27 18:03 ` Jose E. Marchesi
2021-11-28 1:57 ` Guillermo Martinez
2021-11-28 1:56 ` [PATCH v2] " Guillermo E. Martinez
1 sibling, 1 reply; 7+ messages in thread
From: Jose E. Marchesi @ 2021-11-27 18:03 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
> Hello libabigail team,
>
> This patch fix the `length' property of `subrange' node when
> we define a dynamic length array,
>
> Please let me know your comments,
>
> Thanks in advanced!,
> Guillermo
>
> Defining an array type with dynamic length, node `subrange'
> in the abixml file doesn't write the accurate `length'
> property `infinite', instead `1' is written:
> <subrange length='1' .../>
>
> So, member function `array_type_def::subrange_type::is_infinite'
> is set when `upper_bound' value is equal to `0' or UINT64_MAX.
>
> * src/abg-ctf-reader.cc (process_ctf_array_type):
> set subrange_type::is_infinite when `upper_bound' value
> is equal to `0' or UINT64_MAX.
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
> ---
> src/abg-ctf-reader.cc | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> index c571d825..687686d9 100644
> --- a/src/abg-ctf-reader.cc
> +++ b/src/abg-ctf-reader.cc
> @@ -472,6 +472,7 @@ process_ctf_array_type(read_context *ctxt,
> {
> array_type_def_sptr result;
> ctf_arinfo_t ctf_ainfo;
> + bool is_infinite = false;
>
> /* First, get the information about the CTF array. */
> if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
> @@ -507,6 +508,19 @@ process_ctf_array_type(read_context *ctxt,
> lower_bound.set_unsigned(0); /* CTF supports C only. */
> upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
>
> + if (upper_bound.get_unsigned_value() == 0)
> + {
> + is_infinite = true;
> + }
These braces are superfluous.
> + if (UINT64_MAX == upper_bound.get_unsigned_value())
> + {
> + // If the upper_bound size is the max of the integer value, then
> + // it most certainly means infinite size.
> + is_infinite = true;
> + upper_bound.set_unsigned(0);
> + }
Is that specified by the CTF spec?
> +
> subrange.reset(new array_type_def::subrange_type(ctxt->ir_env,
> "",
> lower_bound,
> @@ -517,6 +531,12 @@ process_ctf_array_type(read_context *ctxt,
> if (!subrange)
> return result;
>
> + subrange->is_infinite(is_infinite);
> + ABG_ASSERT(subrange->is_infinite()
> + || (subrange->get_length() ==
> + (uint64_t) (subrange->get_upper_bound()
> + - subrange->get_lower_bound() + 1)));
Hm why this assert?
> +
> add_decl_to_scope(subrange, tunit->get_global_scope());
> canonicalize(subrange);
> subranges.push_back(subrange);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] ctf-reader: Fix length in dynamic array definition
2021-11-26 23:17 [PATCH] ctf-reader: Fix length in dynamic array definition Guillermo E. Martinez
2021-11-27 18:03 ` Jose E. Marchesi
@ 2021-11-28 1:56 ` Guillermo E. Martinez
2021-11-29 13:32 ` Jose E. Marchesi
2021-12-14 11:20 ` Dodji Seketeli
1 sibling, 2 replies; 7+ messages in thread
From: Guillermo E. Martinez @ 2021-11-28 1:56 UTC (permalink / raw)
To: libabigail
Defining an array type with dynamic length, node `subrange'
in the abixml file doesn't write the accurate `length'
property `infinite', instead `1' is written:
<subrange length='1' .../>
So, member function `array_type_def::subrange_type::is_infinite'
is set when `upper_bound' value is equal to `0'.
* src/abg-ctf-reader.cc (process_ctf_array_type):
set subrange_type::is_infinite when `upper_bound' value
is equal to `0'.
Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
---
src/abg-ctf-reader.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index c571d825..fbf6baef 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -472,6 +472,7 @@ process_ctf_array_type(read_context *ctxt,
{
array_type_def_sptr result;
ctf_arinfo_t ctf_ainfo;
+ bool is_infinite = false;
/* First, get the information about the CTF array. */
if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
@@ -507,6 +508,10 @@ process_ctf_array_type(read_context *ctxt,
lower_bound.set_unsigned(0); /* CTF supports C only. */
upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
+ /* for VLAs number of array elements is 0 */
+ if (upper_bound.get_unsigned_value() == 0)
+ is_infinite = true;
+
subrange.reset(new array_type_def::subrange_type(ctxt->ir_env,
"",
lower_bound,
@@ -517,6 +522,7 @@ process_ctf_array_type(read_context *ctxt,
if (!subrange)
return result;
+ subrange->is_infinite(is_infinite);
add_decl_to_scope(subrange, tunit->get_global_scope());
canonicalize(subrange);
subranges.push_back(subrange);
--
2.33.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ctf-reader: Fix length in dynamic array definition
2021-11-27 18:03 ` Jose E. Marchesi
@ 2021-11-28 1:57 ` Guillermo Martinez
0 siblings, 0 replies; 7+ messages in thread
From: Guillermo Martinez @ 2021-11-28 1:57 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail, Jose Marchesi
On Saturday, November 27, 2021 12:03:23 PM CST Jose E. Marchesi wrote:
>
> > Hello libabigail team,
> >
> > This patch fix the `length' property of `subrange' node when
> > we define a dynamic length array,
> >
> > Please let me know your comments,
> >
> > Thanks in advanced!,
> > Guillermo
> >
> > Defining an array type with dynamic length, node `subrange'
> > in the abixml file doesn't write the accurate `length'
> > property `infinite', instead `1' is written:
> > <subrange length='1' .../>
> >
> > So, member function `array_type_def::subrange_type::is_infinite'
> > is set when `upper_bound' value is equal to `0' or UINT64_MAX.
> >
> > * src/abg-ctf-reader.cc (process_ctf_array_type):
> > set subrange_type::is_infinite when `upper_bound' value
> > is equal to `0' or UINT64_MAX.
> >
> > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
> > ---
> > src/abg-ctf-reader.cc | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> > index c571d825..687686d9 100644
> > --- a/src/abg-ctf-reader.cc
> > +++ b/src/abg-ctf-reader.cc
> > @@ -472,6 +472,7 @@ process_ctf_array_type(read_context *ctxt,
> > {
> > array_type_def_sptr result;
> > ctf_arinfo_t ctf_ainfo;
> > + bool is_infinite = false;
> >
> > /* First, get the information about the CTF array. */
> > if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
> > @@ -507,6 +508,19 @@ process_ctf_array_type(read_context *ctxt,
> > lower_bound.set_unsigned(0); /* CTF supports C only. */
> > upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
> >
> > + if (upper_bound.get_unsigned_value() == 0)
> > + {
> > + is_infinite = true;
> > + }
>
> These braces are superfluous.
OK, I'll will remove curly braces in next version.
> > + if (UINT64_MAX == upper_bound.get_unsigned_value())
> > + {
> > + // If the upper_bound size is the max of the integer value, then
> > + // it most certainly means infinite size.
> > + is_infinite = true;
> > + upper_bound.set_unsigned(0);
> > + }
>
> Is that specified by the CTF spec?
Ohh .. sorry is for DWARF, will be remove in next patch.
> > +
> > subrange.reset(new array_type_def::subrange_type(ctxt->ir_env,
> > "",
> > lower_bound,
> > @@ -517,6 +531,12 @@ process_ctf_array_type(read_context *ctxt,
> > if (!subrange)
> > return result;
> >
> > + subrange->is_infinite(is_infinite);
> > + ABG_ASSERT(subrange->is_infinite()
> > + || (subrange->get_length() ==
> > + (uint64_t) (subrange->get_upper_bound()
> > + - subrange->get_lower_bound() + 1)));
>
> Hm why this assert?
After previous comment it's not required.
>
> > +
> > add_decl_to_scope(subrange, tunit->get_global_scope());
> > canonicalize(subrange);
> > subranges.push_back(subrange);
>
Thanks Jose!
guillermo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] ctf-reader: Fix length in dynamic array definition
2021-11-28 1:56 ` [PATCH v2] " Guillermo E. Martinez
@ 2021-11-29 13:32 ` Jose E. Marchesi
2021-12-10 3:00 ` Guillermo Martinez
2021-12-14 11:20 ` Dodji Seketeli
1 sibling, 1 reply; 7+ messages in thread
From: Jose E. Marchesi @ 2021-11-29 13:32 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
> Defining an array type with dynamic length, node `subrange'
> in the abixml file doesn't write the accurate `length'
> property `infinite', instead `1' is written:
> <subrange length='1' .../>
>
> So, member function `array_type_def::subrange_type::is_infinite'
> is set when `upper_bound' value is equal to `0'.
>
> * src/abg-ctf-reader.cc (process_ctf_array_type):
> set subrange_type::is_infinite when `upper_bound' value
> is equal to `0'.
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
LGTM
> ---
> src/abg-ctf-reader.cc | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
> index c571d825..fbf6baef 100644
> --- a/src/abg-ctf-reader.cc
> +++ b/src/abg-ctf-reader.cc
> @@ -472,6 +472,7 @@ process_ctf_array_type(read_context *ctxt,
> {
> array_type_def_sptr result;
> ctf_arinfo_t ctf_ainfo;
> + bool is_infinite = false;
>
> /* First, get the information about the CTF array. */
> if (static_cast<ctf_id_t>(ctf_array_info(ctf_dictionary,
> @@ -507,6 +508,10 @@ process_ctf_array_type(read_context *ctxt,
> lower_bound.set_unsigned(0); /* CTF supports C only. */
> upper_bound.set_unsigned(nelems > 0 ? nelems - 1 : 0U);
>
> + /* for VLAs number of array elements is 0 */
> + if (upper_bound.get_unsigned_value() == 0)
> + is_infinite = true;
> +
> subrange.reset(new array_type_def::subrange_type(ctxt->ir_env,
> "",
> lower_bound,
> @@ -517,6 +522,7 @@ process_ctf_array_type(read_context *ctxt,
> if (!subrange)
> return result;
>
> + subrange->is_infinite(is_infinite);
> add_decl_to_scope(subrange, tunit->get_global_scope());
> canonicalize(subrange);
> subranges.push_back(subrange);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] ctf-reader: Fix length in dynamic array definition
2021-11-29 13:32 ` Jose E. Marchesi
@ 2021-12-10 3:00 ` Guillermo Martinez
0 siblings, 0 replies; 7+ messages in thread
From: Guillermo Martinez @ 2021-12-10 3:00 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail, Jose Marchesi
Ping ...
On Monday, November 29, 2021 7:32:54 AM CST Jose E. Marchesi wrote:
>
> > Defining an array type with dynamic length, node `subrange'
> > in the abixml file doesn't write the accurate `length'
> > property `infinite', instead `1' is written:
> > <subrange length='1' .../>
> >
> > So, member function `array_type_def::subrange_type::is_infinite'
> > is set when `upper_bound' value is equal to `0'.
> >
> > * src/abg-ctf-reader.cc (process_ctf_array_type):
> > set subrange_type::is_infinite when `upper_bound' value
> > is equal to `0'.
> >
> > Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
>
> LGTM
> > ---
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] ctf-reader: Fix length in dynamic array definition
2021-11-28 1:56 ` [PATCH v2] " Guillermo E. Martinez
2021-11-29 13:32 ` Jose E. Marchesi
@ 2021-12-14 11:20 ` Dodji Seketeli
1 sibling, 0 replies; 7+ messages in thread
From: Dodji Seketeli @ 2021-12-14 11:20 UTC (permalink / raw)
To: Guillermo E. Martinez via Libabigail
"Guillermo E. Martinez via Libabigail" <libabigail@sourceware.org> a
écrit:
> Defining an array type with dynamic length, node `subrange'
> in the abixml file doesn't write the accurate `length'
> property `infinite', instead `1' is written:
> <subrange length='1' .../>
>
> So, member function `array_type_def::subrange_type::is_infinite'
> is set when `upper_bound' value is equal to `0'.
>
> * src/abg-ctf-reader.cc (process_ctf_array_type):
> set subrange_type::is_infinite when `upper_bound' value
> is equal to `0'.
>
> Signed-off-by: Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
Applied to master. Thanks!
Cheers,
--
Dodji
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-12-14 11:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 23:17 [PATCH] ctf-reader: Fix length in dynamic array definition Guillermo E. Martinez
2021-11-27 18:03 ` Jose E. Marchesi
2021-11-28 1:57 ` Guillermo Martinez
2021-11-28 1:56 ` [PATCH v2] " Guillermo E. Martinez
2021-11-29 13:32 ` Jose E. Marchesi
2021-12-10 3:00 ` Guillermo Martinez
2021-12-14 11:20 ` Dodji Seketeli
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).