From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3554 invoked by alias); 10 Jan 2011 20:00:40 -0000 Received: (qmail 3536 invoked by uid 22791); 10 Jan 2011 20:00:39 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_05,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,TW_CP,TW_YY X-Spam-Check-By: sourceware.org Received: from smtp20.nijmegen.internl.net (HELO smtp20.nijmegen.internl.net) (217.149.192.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Jan 2011 20:00:32 +0000 Received: from cnoc.nl.alt001.com (51-24.bbned.dsl.internl.net [82.215.24.51]) by smtp20.nijmegen.internl.net (8.13.8/2.04) with ESMTP id p0AK0SGp027499 for ; Mon, 10 Jan 2011 21:00:28 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by cnoc.nl.alt001.com (Postfix) with ESMTP id 358C5BF24 for ; Mon, 10 Jan 2011 21:00:33 +0100 (CET) Received: from cnoc.nl.alt001.com ([127.0.0.1]) by localhost (cnoc.nl.alt001.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lg-wqHEmjncC for ; Mon, 10 Jan 2011 21:00:30 +0100 (CET) Received: from [192.168.3.251] (host251.cnoc.intern [192.168.3.251]) (using SSLv3 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cnoc.nl.alt001.com (Postfix) with ESMTPS id CBA15BF1F for ; Mon, 10 Jan 2011 21:00:30 +0100 (CET) Subject: Pascal and case sensitivity From: Joost van der Sluis To: gdb@sourceware.org Content-Type: multipart/mixed; boundary="=-15sDkIwGCGWFO3gZoh10" Date: Mon, 10 Jan 2011 20:00:00 -0000 Message-Id: <1294689625.13182.46.camel@wsjoost.cnoc.lan> Mime-Version: 1.0 X-Spam-Scanned: InterNLnet Mail Scan System V2.03 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00028.txt.bz2 --=-15sDkIwGCGWFO3gZoh10 Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 540 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. --=-15sDkIwGCGWFO3gZoh10 Content-Disposition: attachment; filename="gdb_case_insensitive_patch2.diff" Content-Type: text/x-patch; name="gdb_case_insensitive_patch2.diff"; charset="UTF-8" Content-Transfer-Encoding: 7bit Content-length: 5232 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; --=-15sDkIwGCGWFO3gZoh10--