This is the mail archive of the gdb-patches@sources.redhat.com 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: PATCH: Start Fortran support for variable objects.


 > Also, I'm beginning to wonder if you're doing this in the right place. 
 > Not that it matters a whole lot, but index is 0-based in every other
 > case, including for structs.  Maybe the children of arr(4) should be
 > arr.0 == arr(1), arr.1 == arr(2), arr.2 == arr(3), arr.3 == arr(4). 
 > Then you'd add the lower bound in c_value_of_child.  Does that work?
 > Do you have an opinion on which is "more right"?

Unfortunately the index for "name" is used to compute the expression "exp"
(which makes it a bit redundant):

      INTEGER ARRAY2(-1:4)

Zero based gives:

(gdb) 
-var-list-children var1
^done,numchild="6",children=[child={name="var1.0",exp="0",numchild="0",type="integer"},child={name="var1.1",exp="1",numchild="0",type="integer"}...

My patch currently gives:

(gdb) 
-var-list-children var1
^done,numchild="6",children=[child={name="var1.-1",exp="-1",numchild="0",type="integer"},child={name="var1.0",exp="0",numchild="0",type="integer"}...

As (I think) you say, ideal would be:

(gdb) 
-var-list-children var1
^done,numchild="6",children=[child={name="var1.0",exp="-1",numchild="0",type="integer"},child={name="var1.1",exp="0",numchild="0",type="integer"}...


In any case it would make sense to compute the offset outside the loop as
shown below.

Nick


  type = get_type (var);
  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
    j = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (var->type));
  else
    j = 0;

  for (i = 0; i < var->num_children; i++)
    {
      /* Mark as the end in case we bail out */
      *((*childlist) + i) = NULL;


      /* check if child exists, if not create */
      name = name_of_child (var, i + j);
      child = child_exists (var, name);
      if (child == NULL)
	  child = create_child (var, i + j, name);

      *((*childlist) + i) = child;
    }


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