This is the mail archive of the gdb@sourceware.org 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 for allowing calling pascal-methods (fpc)


On Wed, 2011-10-05 at 12:14 -0600, Tom Tromey wrote:
> >>>>> "Joost" == Joost van der Sluis <joost@cnoc.nl> writes:
> 
> Joost> More digging convinced me that the actual problem is in
> Joost> lookup_struct_elt_type. 
> 
> Could you explain why?

Well, the comment says it should: "Given a type TYPE, lookup the type of
the component of type named NAME". Now it does do that for fields, but
not for the FN fields. With the result that the Pascal-parser can not
handle those FN fields. (They are called FN fields, but they are in fact
(virtual)-classes related fields, so they also apply to Pascal)

> I am not sure that applying this patch is ok.  It is generic code, so
> this change may negatively affect other languages -- it is hard to be
> sure without replicating your analysis.

Thing is that this function is only used by the Pascal parser, and
within the ada-lang.c file. So it could be useful if someone with more
ada-knowledge could have a look at it. (I did have gnat installed when
doing the test-runs)

> Perhaps some other Pascal-specific fix would be more obviously safe.

I could copy lookup_struct_elt_type under a different name to p-lang.c,
and change it there. 

I could also create a wrapper-function in p-lang.c, that calls
lookup_struct_elt_type and then does the additional search within the
FN-fields. But that's very difficult (impossible?), because of the
inheritance: A field has to be searched first within it's own class, and
only if it's not found in it's base-classes.

> Do you have copyright papers in place?  If not, contact me off-list to
> get started.

Yes, those are in place.

> Joost> Attached is a patch which makes it possible for gdb to call methods and
> Joost> print the result. A testsuite-run did not show any regressions. The
> Joost> patch also contains a test with an example.
> 
> Patches should go to gdb-patches and have a ChangeLog entry.
> See gdb/CONTRIBUTE.
> 
> Joost> +      if (t_method_name && (strcmp_iw (t_method_name, name) == 0))
> Joost> +	{
> Joost> +          if (TYPE_FN_FIELDLIST_LENGTH(type, i) == 1)
> Joost> +            {
> Joost> +              return TYPE_FN_FIELD_TYPE (TYPE_FN_FIELDLIST1 (type, i), 0);
> Joost> +            }
> Joost> +          else if (!(noerr))
> Joost> +            error (_("Could not determine which %s has to be used."), name);
> 
> This seems iffy for C++.

I agree, but there is more in lookup_struct_elt_type that's iffy for C
++. But it's ada and Pascal only.

Joost


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