This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] language support: case sensitivity
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [PATCH] language support: case sensitivity
- From: Jimmy Guo <guo at cup dot hp dot com>
- Date: Tue, 1 Aug 2000 15:24:37 -0700 (PDT)
This patch adds case sensivity support and sets language specific case
sensitivity setting to *_language_defn. This is necessary to support
Fortran symbol lookup which is case insensitive.
Tue Aug 1 15:02:17 Jimmy Guo <guo@cup.hp.com>
* language.h: Add enum case_mode, case_sensitivity.
* language.c: Define case_mode, case_sensitivity. Set case
sensitivity on for unknown_language_defn, auto_language_defn,
and local_language_defn.
(show_case_command,set_case_command,set_case_str): New static func.
(set_type_range_case): New static func, replaces set_type_range ().
(set_language_command,set_type_command,set_range_command,set_language):
Call set_type_range_case ().
(language_info): Print case sensitivity setting.
(_initialize_language): Add set/show commands for 'case-sensitive'.
Set default case mode 'auto'. Set default language 'auto'.
* c-lang.c: Set case sensitivity on for c_language_defn,
cplus_language_defn, and asm_language_defn.
* ch-lang.c: Set case sensitivity on for chill_language_defn.
* f-lang.c: Set case sensivitity off for f_language_defn.
* jv-lang.c: Set case sensitivity on for java_language_defn.
* m2-lang.c: Set case sensitivity on for m2_language_defn.
* p-lang.c: Set case sensitivity on for pascal_language_defn.
* scm-lang.c: Set case sensitivity on for scm_language_defn.
* symtab.c (lookup_symbol): Downcase symbol name if case sensivitity
is off.
Index: language.h
/usr/local/bin/diff -c -L language.h language.h@@/main/cygnus/10 language.h
*** language.h
--- language.h Tue Aug 1 13:37:53 2000
***************
*** 81,86 ****
--- 81,106 ----
type_check_off, type_check_warn, type_check_on
}
type_check;
+
+ /* case_mode ==
+ case_mode_auto: case_sensitivity set upon selection of scope
+ case_mode_manual: case_sensitivity set only by user. */
+
+ extern enum case_mode
+ {
+ case_mode_auto, case_mode_manual
+ }
+ case_mode;
+
+ /* case_sensitivity ==
+ case_sensitive_on: Case sensitivity in name matching is used
+ case_sensitive_off: Case sensitivity in name matching is not used */
+
+ extern enum case_sensitivity
+ {
+ case_sensitive_on, case_sensitive_off
+ }
+ case_sensitivity;
/* Information for doing language dependent formatting of printed values. */
***************
*** 139,144 ****
--- 159,167 ----
/* Default type checking */
enum type_check la_type_check;
+
+ /* Default case sensitivity */
+ enum case_sensitivity la_case_sensitivity;
/* Parser function. */
Index: language.c
/usr/local/bin/diff -c -L language.c language.c@@/main/cygnus/14 language.c
*** language.c
--- language.c Tue Aug 1 14:34:06 2000
***************
*** 57,62 ****
--- 57,68 ----
static void set_range_command (char *, int);
+ static void show_case_command (char *, int);
+
+ static void set_case_command (char *, int);
+
+ static void set_case_str (void);
+
static void set_range_str (void);
static void set_type_str (void);
***************
*** 71,77 ****
static void set_check (char *, int);
! static void set_type_range (void);
static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
--- 77,83 ----
static void set_check (char *, int);
! static void set_type_range_case (void);
static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
***************
*** 105,110 ****
--- 111,118 ----
enum range_check range_check = range_check_off;
enum type_mode type_mode = type_mode_auto;
enum type_check type_check = type_check_off;
+ enum case_mode case_mode = case_mode_auto;
+ enum case_sensitivity case_sensitivity = case_sensitive_on;
/* The current language and language_mode (see language.h) */
***************
*** 132,137 ****
--- 140,146 ----
static char *language;
static char *type;
static char *range;
+ static char *case_sensitive;
/* Warning issued when current_language and the language of the current
frame do not match. */
***************
*** 215,221 ****
/* Enter manual mode. Set the specified language. */
language_mode = language_mode_manual;
current_language = languages[i];
! set_type_range ();
set_lang_str ();
expected_language = current_language;
return;
--- 224,230 ----
/* Enter manual mode. Set the specified language. */
language_mode = language_mode_manual;
current_language = languages[i];
! set_type_range_case ();
set_lang_str ();
expected_language = current_language;
return;
***************
*** 267,275 ****
else if (STREQ (type, "auto"))
{
type_mode = type_mode_auto;
! set_type_range ();
/* Avoid hitting the set_type_str call below. We
! did it in set_type_range. */
return;
}
else
--- 276,284 ----
else if (STREQ (type, "auto"))
{
type_mode = type_mode_auto;
! set_type_range_case ();
/* Avoid hitting the set_type_str call below. We
! did it in set_type_range_case. */
return;
}
else
***************
*** 317,325 ****
else if (STREQ (range, "auto"))
{
range_mode = range_mode_auto;
! set_type_range ();
/* Avoid hitting the set_range_str call below. We
! did it in set_type_range. */
return;
}
else
--- 326,334 ----
else if (STREQ (range, "auto"))
{
range_mode = range_mode_auto;
! set_type_range_case ();
/* Avoid hitting the set_range_str call below. We
! did it in set_type_range_case. */
return;
}
else
***************
*** 330,341 ****
show_range_command ((char *) 0, from_tty);
}
! /* Set the status of range and type checking based on
the current modes and the current language.
If SHOW is non-zero, then print out the current language,
type and range checking status. */
static void
! set_type_range ()
{
if (range_mode == range_mode_auto)
--- 339,394 ----
show_range_command ((char *) 0, from_tty);
}
! /* Show command. Display a warning if the case sensitivity setting does
! not match the current language. */
! static void
! show_case_command(ignore, from_tty)
! char *ignore;
! int from_tty;
! {
! if (case_sensitivity != current_language->la_case_sensitivity)
! printf_unfiltered(
! "Warning: the current case sensitivity setting does not match the language.\n");
! }
!
! /* Set command. Change the setting for case sensitivity. */
! static void
! set_case_command(ignore, from_tty)
! char *ignore;
! int from_tty;
! {
! if (STREQ (case_sensitive, "on"))
! {
! case_sensitivity = case_sensitive_on;
! case_mode = case_mode_manual;
! }
! else if (STREQ (case_sensitive, "off"))
! {
! case_sensitivity = case_sensitive_off;
! case_mode = case_mode_manual;
! }
! else if (STREQ (case_sensitive, "auto"))
! {
! case_mode = case_mode_auto;
! set_type_range_case ();
! /* Avoid hitting the set_case_str call below. We
! did it in set_type_range_case. */
! return;
! }
! else
! {
! warning ("Unrecognized case-sensitive setting: \"%s\"", case_sensitive);
! }
! set_case_str();
! show_case_command ((char *) NULL, from_tty);
! }
!
! /* Set the status of range and type checking and case sensitivity based on
the current modes and the current language.
If SHOW is non-zero, then print out the current language,
type and range checking status. */
static void
! set_type_range_case ()
{
if (range_mode == range_mode_auto)
***************
*** 344,351 ****
--- 397,408 ----
if (type_mode == type_mode_auto)
type_check = current_language->la_type_check;
+ if (case_mode == case_mode_auto)
+ case_sensitivity = current_language->la_case_sensitivity;
+
set_type_str ();
set_range_str ();
+ set_case_str ();
}
/* Set current language to (enum language) LANG. Returns previous language. */
***************
*** 364,370 ****
if (languages[i]->la_language == lang)
{
current_language = languages[i];
! set_type_range ();
set_lang_str ();
break;
}
--- 421,427 ----
if (languages[i]->la_language == lang)
{
current_language = languages[i];
! set_type_range_case ();
set_lang_str ();
break;
}
***************
*** 444,449 ****
--- 501,529 ----
range = concat (pref, tmp, NULL);
}
+ static void
+ set_case_str()
+ {
+ char *tmp = NULL, *prefix = "";
+
+ if (case_mode==case_mode_auto)
+ prefix = "auto; currently ";
+
+ switch (case_sensitivity)
+ {
+ case case_sensitive_on:
+ tmp = "on";
+ break;
+ case case_sensitive_off:
+ tmp = "off";
+ break;
+ default:
+ error ("Unrecognized case-sensitive setting.");
+ }
+
+ free (case_sensitive);
+ case_sensitive = concat (prefix, tmp, NULL);
+ }
/* Print out the current language settings: language, range and
type checking. If QUIETLY, print only what has changed. */
***************
*** 465,470 ****
--- 545,552 ----
show_type_command ((char *) 0, 1);
printf_unfiltered ("Range checking: %s\n", range);
show_range_command ((char *) 0, 1);
+ printf_unfiltered ("Case sensitivity: %s\n", case_sensitive);
+ show_case_command ((char *) 0, 1);
}
}
***************
*** 1477,1482 ****
--- 1559,1565 ----
&unknown_builtin_types[0],
range_check_off,
type_check_off,
+ case_sensitive_on,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
***************
*** 1506,1511 ****
--- 1589,1595 ----
&unknown_builtin_types[0],
range_check_off,
type_check_off,
+ case_sensitive_on,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
***************
*** 1534,1539 ****
--- 1618,1624 ----
&unknown_builtin_types[0],
range_check_off,
type_check_off,
+ case_sensitive_on,
unk_lang_parser,
unk_lang_error,
evaluate_subexp_standard,
***************
*** 1600,1615 ****
set->function.cfunc = set_range_command;
show->function.cfunc = show_range_command;
add_language (&unknown_language_defn);
add_language (&local_language_defn);
add_language (&auto_language_defn);
language = savestring ("auto", strlen ("auto"));
- set_language_command (language, 0);
-
type = savestring ("auto", strlen ("auto"));
- set_type_command (NULL, 0);
-
range = savestring ("auto", strlen ("auto"));
! set_range_command (NULL, 0);
}
--- 1685,1708 ----
set->function.cfunc = set_range_command;
show->function.cfunc = show_range_command;
+ set = add_set_cmd ("case-sensitive", class_support, var_string_noescape,
+ (char *) &case_sensitive,
+ "Set case sensitivity in name search. (on/off/auto)\n\
+ For Fortran the default is off; for other languages the default is on.",
+ &setlist);
+ show = add_show_from_set (set, &showlist);
+ set->function.cfunc = set_case_command;
+ show->function.cfunc = show_case_command;
+
add_language (&unknown_language_defn);
add_language (&local_language_defn);
add_language (&auto_language_defn);
language = savestring ("auto", strlen ("auto"));
type = savestring ("auto", strlen ("auto"));
range = savestring ("auto", strlen ("auto"));
! case_sensitive = savestring ("auto",strlen ("auto"));
!
! /* Have the above take effect */
! set_language (language_auto);
}
Index: c-lang.c
/usr/local/bin/diff -c -L c-lang.c c-lang.c@@/main/cygnus/9 c-lang.c
*** c-lang.c
--- c-lang.c Tue Aug 1 14:36:59 2000
***************
*** 420,425 ****
--- 420,426 ----
c_builtin_types,
range_check_off,
type_check_off,
+ case_sensitive_on,
c_parse,
c_error,
evaluate_subexp_standard,
***************
*** 471,476 ****
--- 472,478 ----
cplus_builtin_types,
range_check_off,
type_check_off,
+ case_sensitive_on,
c_parse,
c_error,
evaluate_subexp_standard,
***************
*** 499,504 ****
--- 501,507 ----
c_builtin_types,
range_check_off,
type_check_off,
+ case_sensitive_on,
c_parse,
c_error,
evaluate_subexp_standard,
Index: ch-lang.c
/usr/local/bin/diff -c -L ch-lang.c ch-lang.c@@/main/cygnus/7 ch-lang.c
*** ch-lang.c
--- ch-lang.c Tue Aug 1 14:38:14 2000
***************
*** 625,630 ****
--- 625,631 ----
chill_builtin_types,
range_check_on,
type_check_on,
+ case_sensitive_on,
chill_parse, /* parser */
chill_error, /* parser error function */
evaluate_subexp_chill,
Index: f-lang.c
/usr/local/bin/diff -c -L f-lang.c f-lang.c@@/main/cygnus/9 f-lang.c
*** f-lang.c
--- f-lang.c Tue Aug 1 14:39:34 2000
***************
*** 471,476 ****
--- 471,477 ----
f_builtin_types,
range_check_on,
type_check_on,
+ case_sensitive_off,
f_parse, /* parser */
f_error, /* parser error function */
evaluate_subexp_standard,
Index: jv-lang.c
/usr/local/bin/diff -c -L jv-lang.c jv-lang.c@@/main/cygnus/8 jv-lang.c
*** jv-lang.c
--- jv-lang.c Tue Aug 1 14:40:45 2000
***************
*** 1065,1070 ****
--- 1065,1071 ----
c_builtin_types,
range_check_off,
type_check_off,
+ case_sensitive_on,
java_parse,
java_error,
evaluate_subexp_java,
Index: m2-lang.c
/usr/local/bin/diff -c -L m2-lang.c m2-lang.c@@/main/cygnus/7 m2-lang.c
*** m2-lang.c
--- m2-lang.c Tue Aug 1 14:41:53 2000
***************
*** 425,430 ****
--- 425,431 ----
m2_builtin_types,
range_check_on,
type_check_on,
+ case_sensitive_on,
m2_parse, /* parser */
m2_error, /* parser error function */
evaluate_subexp_standard,
Index: p-lang.c
/usr/local/bin/diff -c -L p-lang.c p-lang.c@@/main/cygnus/0 p-lang.c
*** p-lang.c
--- p-lang.c Tue Aug 1 14:42:44 2000
***************
*** 402,407 ****
--- 402,408 ----
pascal_builtin_types,
range_check_on,
type_check_on,
+ case_sensitive_on,
pascal_parse,
pascal_error,
evaluate_subexp_standard,
Index: scm-lang.c
/usr/local/bin/diff -c -L scm-lang.c scm-lang.c@@/main/cygnus/7 scm-lang.c
*** scm-lang.c
--- scm-lang.c Tue Aug 1 14:43:39 2000
***************
*** 251,256 ****
--- 251,257 ----
c_builtin_types,
range_check_off,
type_check_off,
+ case_sensitive_on,
scm_parse,
c_error,
evaluate_subexp_scm,
Index: symtab.c
/usr/local/bin/diff -c -L symtab.c symtab.c@@/main/cygnus/22 symtab.c
*** symtab.c
--- symtab.c Tue Aug 1 13:31:54 2000
***************
*** 606,617 ****
register struct objfile *objfile = NULL;
register struct block *b;
register struct minimal_symbol *msymbol;
/* Search specified block and its superiors. */
while (block != 0)
{
! sym = lookup_block_symbol (block, name, namespace);
if (sym)
{
block_found = block;
--- 606,630 ----
register struct objfile *objfile = NULL;
register struct block *b;
register struct minimal_symbol *msymbol;
+ char *copy;
+ int len, i;
+
+ if (case_sensitivity == case_sensitive_on)
+ copy = (char *) name;
+ else
+ {
+ len = strlen (name);
+ copy = (char *) alloca (len + 1);
+ for (i= 0; i < len; i++)
+ copy[i] = tolower (name[i]);
+ copy[len] = 0;
+ }
/* Search specified block and its superiors. */
while (block != 0)
{
! sym = lookup_block_symbol (block, copy, namespace);
if (sym)
{
block_found = block;
***************
*** 664,670 ****
if (BLOCK_START (b) <= BLOCK_START (block)
&& BLOCK_END (b) > BLOCK_START (block))
{
! sym = lookup_block_symbol (b, name, VAR_NAMESPACE);
if (sym)
{
block_found = b;
--- 677,683 ----
if (BLOCK_START (b) <= BLOCK_START (block)
&& BLOCK_END (b) > BLOCK_START (block))
{
! sym = lookup_block_symbol (b, copy, VAR_NAMESPACE);
if (sym)
{
block_found = b;
***************
*** 684,690 ****
struct value *v = value_of_this (0);
*is_a_field_of_this = 0;
! if (v && check_field (v, name))
{
*is_a_field_of_this = 1;
if (symtab != NULL)
--- 697,703 ----
struct value *v = value_of_this (0);
*is_a_field_of_this = 0;
! if (v && check_field (v, copy))
{
*is_a_field_of_this = 1;
if (symtab != NULL)
***************
*** 702,708 ****
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (sym)
{
block_found = block;
--- 715,721 ----
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (sym)
{
block_found = block;
***************
*** 720,726 ****
if (namespace == VAR_NAMESPACE)
{
! msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
{
s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
--- 733,739 ----
if (namespace == VAR_NAMESPACE)
{
! msymbol = lookup_minimal_symbol (copy, NULL, NULL);
if (msymbol != NULL)
{
s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
***************
*** 760,766 ****
}
else if (MSYMBOL_TYPE (msymbol) != mst_text
&& MSYMBOL_TYPE (msymbol) != mst_file_text
! && !STREQ (name, SYMBOL_NAME (msymbol)))
{
/* This is a mangled variable, look it up by its
mangled name. */
--- 773,779 ----
}
else if (MSYMBOL_TYPE (msymbol) != mst_text
&& MSYMBOL_TYPE (msymbol) != mst_file_text
! && !STREQ (copy, SYMBOL_NAME (msymbol)))
{
/* This is a mangled variable, look it up by its
mangled name. */
***************
*** 777,788 ****
ALL_PSYMTABS (objfile, ps)
{
! if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
--- 790,801 ----
ALL_PSYMTABS (objfile, ps)
{
! if (!ps->readin && lookup_partial_symbol (ps, copy, 1, namespace))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
***************
*** 791,802 ****
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (!sym)
error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>).",
! name, ps->filename, name, name);
}
if (symtab != NULL)
*symtab = s;
--- 804,815 ----
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (!sym)
error ("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>).",
! copy, ps->filename, copy, copy);
}
if (symtab != NULL)
*symtab = s;
***************
*** 815,821 ****
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (sym)
{
block_found = block;
--- 828,834 ----
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (sym)
{
block_found = block;
***************
*** 827,838 ****
ALL_PSYMTABS (objfile, ps)
{
! if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
--- 840,851 ----
ALL_PSYMTABS (objfile, ps)
{
! if (!ps->readin && lookup_partial_symbol (ps, copy, 0, namespace))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
***************
*** 841,852 ****
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, name, namespace);
if (!sym)
error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>).",
! name, ps->filename, name, name);
}
if (symtab != NULL)
*symtab = s;
--- 854,865 ----
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
! sym = lookup_block_symbol (block, copy, namespace);
if (!sym)
error ("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
(if a template, try specifying an instantiation: %s<type>).",
! copy, ps->filename, copy, copy);
}
if (symtab != NULL)
*symtab = s;
***************
*** 873,879 ****
if (namespace == VAR_NAMESPACE)
{
! msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
{
/* OK, we found a minimal symbol in spite of not
--- 886,892 ----
if (namespace == VAR_NAMESPACE)
{
! msymbol = lookup_minimal_symbol (copy, NULL, NULL);
if (msymbol != NULL)
{
/* OK, we found a minimal symbol in spite of not
***************
*** 940,946 ****
*/
else if (MSYMBOL_TYPE (msymbol) != mst_text
&& MSYMBOL_TYPE (msymbol) != mst_file_text
! && !STREQ (name, SYMBOL_NAME (msymbol)))
{
return lookup_symbol (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);
--- 953,959 ----
*/
else if (MSYMBOL_TYPE (msymbol) != mst_text
&& MSYMBOL_TYPE (msymbol) != mst_file_text
! && !STREQ (copy, SYMBOL_NAME (msymbol)))
{
return lookup_symbol (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);