Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] pascal: Add lowercase copy of symbol name
@ 2010-04-29 22:18 Pierre Muller
  2010-04-29 22:32 ` Joel Brobecker
  2010-04-30  7:27 ` Jan Kratochvil
  0 siblings, 2 replies; 5+ messages in thread
From: Pierre Muller @ 2010-04-29 22:18 UTC (permalink / raw)
  To: gdb-patches

  Pascal language is supposed to be 
case insensitive, but until now it is 
not true inside GDB.
  There are several reasons, but some 
would like to get better support for this
feature.
  Here is a step in that direction:
  adding a new pascal_specific field for 
general_symbol_info structure,
  fill it with a lowercase copy of the symbol name
and use that lowercase copy for searches
if case_sensitivityy is off.

  
  I did not yet really decide 
exactly how I am going to use this inside that pascal
expression parser.
  One idea would be to first try an exact match,
and if that fails, try again forcing case_sensitivity to off
temporarily.

Comments?
 



Pierre Muller
Pascal language support maintainer for GDB


2010-04-29  Pierre Muller  <muller@ics.u-strasbg.fr>

	* symtab.h (general_symbol_info): Add pascal_specific field with
	lowercase_name subfield.
	* symtab.c (symbol_init_language_specific): Initialize
	pascal_specific.lowercase_name to NULL.
	(symbol_set_names): Construct lowercase_name string.
	(symbol_search_name): Return LOWERCASE_NAME for pascal language
	if CASE_SENSITIVITY is off.

Index: src/gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.234
diff -u -p -r1.234 symtab.c
--- src/gdb/symtab.c	29 Apr 2010 14:45:38 -0000	1.234
+++ src/gdb/symtab.c	29 Apr 2010 21:51:42 -0000
@@ -353,6 +353,10 @@ symbol_init_language_specific (struct ge
     {
       gsymbol->language_specific.cplus_specific.demangled_name = NULL;
     }
+  else if (gsymbol->language == language_pascal)
+    {
+      gsymbol->language_specific.pascal_specific.lowercase_name = NULL;
+    }
   else
     {
       memset (&gsymbol->language_specific, 0,
@@ -532,6 +536,28 @@ symbol_set_names (struct general_symbol_
       return;
     }
 
+  if (gsymbol->language == language_pascal)
+    {
+      int i;
+      char *lc_name;
+      /* In pascal, we do the symbol lookups using the lowercase name.  */
+      if (!copy_name)
+	gsymbol->name = (char *) linkage_name;
+      else
+	{
+	  gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len +
1);
+	  memcpy (gsymbol->name, linkage_name, len);
+	  gsymbol->name[len] = '\0';
+	}
+      lc_name = obstack_alloc (&objfile->objfile_obstack, len + 1);
+      for (i = 0; i < len; i++)
+	lc_name[i] = tolower (linkage_name[i]);
+      lc_name[len] = '\0';
+      gsymbol->language_specific.pascal_specific.lowercase_name = lc_name;
+      return;
+    }
+
+
   if (objfile->demangled_names_hash == NULL)
     create_demangled_names_hash (objfile);
 
@@ -691,6 +717,10 @@ symbol_search_name (const struct general
 {
   if (gsymbol->language == language_ada)
     return gsymbol->name;
+  else if (gsymbol->language == language_pascal
+	   && case_sensitivity == case_sensitive_off 
+	   && gsymbol->language_specific.pascal_specific.lowercase_name !=
NULL)
+    return gsymbol->language_specific.pascal_specific.lowercase_name;
   else
     return symbol_natural_name (gsymbol);
 }
Index: src/gdb/symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.152
diff -u -p -r1.152 symtab.h
--- src/gdb/symtab.h	22 Apr 2010 23:15:42 -0000	1.152
+++ src/gdb/symtab.h	29 Apr 2010 21:51:45 -0000
@@ -130,6 +130,12 @@ struct general_symbol_info
       char *demangled_name;
     }
     cplus_specific;
+    struct pascal_specific
+    {
+      /* This is used for case insensitive searching.  */
+      char *lowercase_name;
+    }
+    pascal_specific;
   }
   language_specific;
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] pascal: Add lowercase copy of symbol name
  2010-04-29 22:18 [RFC] pascal: Add lowercase copy of symbol name Pierre Muller
@ 2010-04-29 22:32 ` Joel Brobecker
  2010-04-29 22:54   ` Pierre Muller
  2010-04-30  7:27 ` Jan Kratochvil
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2010-04-29 22:32 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

>   Here is a step in that direction: adding a new pascal_specific field
>   for general_symbol_info structure, fill it with a lowercase copy of
>   the symbol name and use that lowercase copy for searches if
>   case_sensitivityy is off.
> 
>   I did not yet really decide exactly how I am going to use this
>   inside that pascal expression parser.  One idea would be to first
>   try an exact match, and if that fails, try again forcing
>   case_sensitivity to off temporarily.
> 
> Comments?

I can't really say that I am fond of this approach - at all. We already
store the linkage name as well as the natural name. Can't you use that
in the language-specific lookup routines to make the search case
insensitive?

There is also something I'm confused about: If Pascal is *not* case-
sensitive, why make the debugger optionally case-sensitive? Why not
always have a case-insensitive interpreter?  You aluded that there were
some reasons...


-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [RFC] pascal: Add lowercase copy of symbol name
  2010-04-29 22:32 ` Joel Brobecker
@ 2010-04-29 22:54   ` Pierre Muller
  2010-04-29 23:09     ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Pierre Muller @ 2010-04-29 22:54 UTC (permalink / raw)
  To: 'Joel Brobecker'; +Cc: gdb-patches

> I can't really say that I am fond of this approach - at all. We already
> store the linkage name as well as the natural name. Can't you use that
> in the language-specific lookup routines to make the search case
> insensitive?

  The problem is that if we want to keep the true case
of the symbols (which I at least want), doing case-insensitive 
searching required practically to lowercase on the fly
all pascal symbol each time an expression is evaluated.
  This is very inefficient.
 
> There is also something I'm confused about: If Pascal is *not* case-
> sensitive, why make the debugger optionally case-sensitive? Why not
> always have a case-insensitive interpreter?  You aluded that there were
> some reasons...
  
  There are some internal functions or variables inside Free Pascal
that are lowercase to avoid possible conflict with
explicitly declared functions or variables (who are completely
UPPERCASED in Free Pascal).
  GNU pascal uses First Letter Capitalization for its
declared function/variables (I don't know the internals of GPC).  
  In the printout, I would like to keep this difference
between internal and declared variables.

  If I have an internal variable named stdout,
and a declared variable STDOUT.
  I would really prefer to still be able to
only get one matching variable if I use the exact matching 
stdout or STDOUT.


Pierre Muller
Pascal language support maintainer for GDB


 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] pascal: Add lowercase copy of symbol name
  2010-04-29 22:54   ` Pierre Muller
@ 2010-04-29 23:09     ` Joel Brobecker
  0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2010-04-29 23:09 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

>   The problem is that if we want to keep the true case of the symbols
>   (which I at least want), doing case-insensitive searching required
>   practically to lowercase on the fly all pascal symbol each time an
>   expression is evaluated.  This is very inefficient.

The way Ada handles this is by lower-casing the expression being used
as the key, and then comparing it with the name stored in our symbol.
For instance, if the user does:

        (gdb) print My_Variable

What GDB does is first lower-case "My_Variable" to "my_variable", and
then do a search of my_variable.

You could transpose that to Pascal by upper-casing My_Variable the
entity name in the expression before doing the search.

>   There are some internal functions or variables inside Free Pascal
>   that are lowercase to avoid possible conflict with explicitly
>   declared functions or variables (who are completely UPPERCASED in
>   Free Pascal).

Using Ada as an example, we have the same sort of issue, and what
we have been using is a special syntax to tell the parser to avoid
the casing-change:

        (gdb) print <My_Variable>

Maybe you can do something similar for Pascal?

-- 
Joel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] pascal: Add lowercase copy of symbol name
  2010-04-29 22:18 [RFC] pascal: Add lowercase copy of symbol name Pierre Muller
  2010-04-29 22:32 ` Joel Brobecker
@ 2010-04-30  7:27 ` Jan Kratochvil
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Kratochvil @ 2010-04-30  7:27 UTC (permalink / raw)
  To: Pierre Muller; +Cc: gdb-patches

On Fri, 30 Apr 2010 00:18:31 +0200, Pierre Muller wrote:
> @@ -130,6 +130,12 @@ struct general_symbol_info
>        char *demangled_name;
>      }
>      cplus_specific;
> +    struct pascal_specific
> +    {
> +      /* This is used for case insensitive searching.  */
> +      char *lowercase_name;
> +    }
> +    pascal_specific;

Independently filed just now PR fortran/11560 with similar problem for
Fortran.

As the Fortran patch uses cplus_specific.demangled_name (or it could start
using new fortran_specific.demangled_name) it would mean full case sensitivity
duplication pascal<->fortran.

I am also rather for some modification of symbol_search_name etc. more in the
PR fortran/11560.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-04-30  7:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-29 22:18 [RFC] pascal: Add lowercase copy of symbol name Pierre Muller
2010-04-29 22:32 ` Joel Brobecker
2010-04-29 22:54   ` Pierre Muller
2010-04-29 23:09     ` Joel Brobecker
2010-04-30  7:27 ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox