From: Joost van der Sluis <joost@cnoc.nl>
To: gdb@sourceware.org
Subject: Pascal and case sensitivity
Date: Mon, 10 Jan 2011 20:00:00 -0000 [thread overview]
Message-ID: <1294689625.13182.46.camel@wsjoost.cnoc.lan> (raw)
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
Hi all,
Attached is patch to fix case-sensitivity issues with Pascal. It first
searches case-sensitive an if an identifier isn't found, a
case-insensitive search is performed.
But this path is quite messy it can be cleaned up somewhat, but it will
never win the 'most beautiful patch' contest. ;)
Would it be acceptable to make the hash (msymbol_hash_iw or dict_hash)
case insensitive by adding a to_lower, and to change strcmp_iw so that
it does a case-insensitive compare when some case-insensitivity setting
is set?
Regards,
Joost.
[-- Attachment #2: gdb_case_insensitive_patch2.diff --]
[-- Type: text/x-patch, Size: 5232 bytes --]
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 9d53ff0..8a04921 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -27,6 +27,7 @@
#include "buildsym.h"
#include "gdb_assert.h"
#include "dictionary.h"
+#include "language.h"
/* This file implements dictionaries, which are tables that associate
symbols to names. They are represented by an opaque type 'struct
@@ -665,11 +666,20 @@ iter_match_first_hashed (const struct dictionary *dict,
sym = sym->hash_next)
{
/* Warning: the order of arguments to compare matters! */
- if (compare (SYMBOL_SEARCH_NAME (sym), name) == 0)
- {
- break;
- }
-
+ if ((current_language->la_language == language_pascal) && (performing_case_sensitive_search == 1) && (original_search_name))
+ {
+ if (compare (SYMBOL_NATURAL_NAME (sym), original_search_name) == 0)
+ {
+ break;
+ }
+ }
+ else
+ {
+ if (compare (SYMBOL_SEARCH_NAME (sym), name) == 0)
+ {
+ break;
+ }
+ }
}
DICT_ITERATOR_CURRENT (iterator) = sym;
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index f7d3035..3476a41 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -177,3 +177,7 @@ extern int dict_size (const struct dictionary *dict);
(sym) = dict_iterator_next (&(iter)))
#endif /* DICTIONARY_H */
+
+int performing_case_sensitive_search;
+char *original_search_name;
+
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 19f5ceb..706205f 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -52,6 +52,7 @@
#include "parser-defs.h"
#include "language.h"
#include "p-lang.h"
+#include "dictionary.h"
#include "bfd.h" /* Required by objfiles.h. */
#include "symfile.h" /* Required by objfiles.h. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
@@ -1445,8 +1446,23 @@ yylex ()
if (is_a_field)
sym = NULL;
else
- sym = lookup_symbol (tmp, expression_context_block,
- VAR_DOMAIN, &is_a_field_of_this);
+ {
+ original_search_name = malloc(100);
+ strcpy (original_search_name,tmp);
+ for (i = 0; i <= namelen; i++)
+ tmp[i] = tolower (tmp[i]);
+
+ performing_case_sensitive_search = 1;
+ sym = lookup_symbol (tmp, expression_context_block,
+ VAR_DOMAIN, &is_a_field_of_this);
+ free(original_search_name);
+ performing_case_sensitive_search = 0;
+ if (!sym)
+ {
+ sym = lookup_symbol (tmp, expression_context_block,
+ VAR_DOMAIN, &is_a_field_of_this);
+ }
+ }
/* second chance uppercased (as Free Pascal does). */
if (!sym && !is_a_field_of_this && !is_a_field)
{
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9d577b0..135269f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -372,6 +372,10 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol,
gsymbol->language_specific.cplus_specific->demangled_name = name;
}
+ else if (gsymbol->language == language_pascal)
+ {
+ gsymbol->language_specific.pascal_specific.lowercase_name = NULL;
+ }
else
gsymbol->language_specific.mangled_lang.demangled_name = name;
}
@@ -594,6 +598,28 @@ symbol_set_names (struct general_symbol_info *gsymbol,
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);
@@ -752,10 +778,19 @@ symbol_demangled_name (const struct general_symbol_info *gsymbol)
char *
symbol_search_name (const struct general_symbol_info *gsymbol)
{
- if (gsymbol->language == language_ada)
- return gsymbol->name;
- else
- return symbol_natural_name (gsymbol);
+ switch (gsymbol->language)
+ {
+ case language_ada:
+ return gsymbol->name;
+ break;
+ case language_pascal:
+ if (gsymbol->language_specific.pascal_specific.lowercase_name != NULL)
+ return gsymbol->language_specific.pascal_specific.lowercase_name;
+ break;
+ default:
+ break;
+ }
+ return symbol_natural_name (gsymbol);
}
/* Initialize the structure fields to zero values. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 944dd33..e371a43 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -138,6 +138,12 @@ struct general_symbol_info
mangled_lang;
struct cplus_specific *cplus_specific;
+ struct pascal_specific
+ {
+ /* This is used for case insensitive searching. */
+ char *lowercase_name;
+ }
+ pascal_specific;
}
language_specific;
next reply other threads:[~2011-01-10 20:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-10 20:00 Joost van der Sluis [this message]
2011-01-10 20:36 ` Jan Kratochvil
2011-01-11 20:53 ` Joost van der Sluis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1294689625.13182.46.camel@wsjoost.cnoc.lan \
--to=joost@cnoc.nl \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox