[v2] ctf-reader: Fix length in dynamic array definition

Message ID 20211128015647.156104-1-guillermo.e.martinez@oracle.com
State New
Headers
Series [v2] ctf-reader: Fix length in dynamic array definition |

Commit Message

Guillermo E. Martinez Nov. 28, 2021, 1:56 a.m. UTC
  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(+)
  

Comments

Jose E. Marchesi Nov. 29, 2021, 1:32 p.m. UTC | #1
> 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);
  
Guillermo E. Martinez Dec. 10, 2021, 3 a.m. UTC | #2
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
> > ---
  
Dodji Seketeli Dec. 14, 2021, 11:20 a.m. UTC | #3
"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,
  

Patch

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