gdb/doc/
* gdb.texinfo (Index Section Format): Change the version to 5. Describe the different formula. gdb/ Case insensitive lookups implementation. * dwarf2read.c: Include ctype.h. (struct mapped_index): New field version. (mapped_index_string_hash): New parameter index_version. New comment for it. Call tolower appropriately. (find_slot_in_mapped_hash): New variable cmp, initialize it, use it. Choose the right index version for mapped_index_string_hash. (dwarf2_read_index): Support also the index version 5. Initialize the new struct mapped_index field version. (hash_strtab_entry): Pass INT_MAX for the new parameter, explain why. (find_slot): Explain the version needs. Pass INT_MAX for the new parameter. (write_psymtabs_to_index): Produce version 5. * minsyms.c (lookup_minimal_symbol): New variable cmp, initialize it, use it. New comment for SYMBOL_MATCHES_SEARCH_NAME. * psymtab.c (lookup_partial_symbol): Find the SYMBOL_MATCHES_SEARCH_NAME start of the found block of matching entries. * symtab.c (lookup_symbol_in_language): Remove the case_sensitive_off NAME lowercasing. (search_symbols): Pass REG_ICASE to regcomp for case_sensitive_off. (completion_list_add_name): New variable ncmp, initialize it, use it. * symtab.h (SYMBOL_HASH_NEXT): Always call tolower. * utils.c (strcmp_iw): Support case_sensitive_off. (strcmp_iw_ordered): Sort in a way compatible with case_sensitive_off. New function comment part. New variables saved_string1, saved_string2 and case_pass. Add a proper second pass. gdb/testsuite/ * gdb.base/fortran-sym-case.c: New file. * gdb.base/fortran-sym-case.exp: New file. * gdb.dwarf2/dw2-case-insensitive-debug.S: New file. * gdb.dwarf2/dw2-case-insensitive.c: New file. * gdb.dwarf2/dw2-case-insensitive.exp: New file.
This commit is contained in:
parent
681bf369ea
commit
559a7a6201
15 changed files with 398 additions and 45 deletions
48
gdb/utils.c
48
gdb/utils.c
|
@ -2974,10 +2974,12 @@ strcmp_iw (const char *string1, const char *string2)
|
|||
{
|
||||
string2++;
|
||||
}
|
||||
if (*string1 != *string2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (case_sensitivity == case_sensitive_on && *string1 != *string2)
|
||||
break;
|
||||
if (case_sensitivity == case_sensitive_off
|
||||
&& (tolower ((unsigned char) *string1)
|
||||
!= tolower ((unsigned char) *string2)))
|
||||
break;
|
||||
if (*string1 != '\0')
|
||||
{
|
||||
string1++;
|
||||
|
@ -2998,6 +3000,10 @@ strcmp_iw (const char *string1, const char *string2)
|
|||
strcmp_iw(LIST_ELT, NAME), then the place to start looking is right
|
||||
where this function would put NAME.
|
||||
|
||||
This function must be neutral to the CASE_SENSITIVITY setting as the user
|
||||
may choose it during later lookup. Therefore this function always sorts
|
||||
primarily case-insensitively and secondarily case-sensitively.
|
||||
|
||||
Here are some examples of why using strcmp to sort is a bad idea:
|
||||
|
||||
Whitespace example:
|
||||
|
@ -3023,8 +3029,10 @@ strcmp_iw (const char *string1, const char *string2)
|
|||
int
|
||||
strcmp_iw_ordered (const char *string1, const char *string2)
|
||||
{
|
||||
/* Formatting stub. */
|
||||
if (1)
|
||||
const char *saved_string1 = string1, *saved_string2 = string2;
|
||||
enum case_sensitivity case_pass = case_sensitive_off;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
|
||||
Provide stub characters if we are already at the end of one of the
|
||||
|
@ -3038,8 +3046,17 @@ strcmp_iw_ordered (const char *string1, const char *string2)
|
|||
while (isspace (*string2))
|
||||
string2++;
|
||||
|
||||
switch (case_pass)
|
||||
{
|
||||
case case_sensitive_off:
|
||||
c1 = tolower ((unsigned char) *string1);
|
||||
c2 = tolower ((unsigned char) *string2);
|
||||
break;
|
||||
case case_sensitive_on:
|
||||
c1 = *string1;
|
||||
c2 = *string2;
|
||||
break;
|
||||
}
|
||||
if (c1 != c2)
|
||||
break;
|
||||
|
||||
|
@ -3057,7 +3074,7 @@ strcmp_iw_ordered (const char *string1, const char *string2)
|
|||
comparison in the cases where one of them is '\0' or '('. */
|
||||
case '\0':
|
||||
if (*string2 == '\0')
|
||||
return 0;
|
||||
break;
|
||||
else
|
||||
return -1;
|
||||
case '(':
|
||||
|
@ -3068,9 +3085,22 @@ strcmp_iw_ordered (const char *string1, const char *string2)
|
|||
default:
|
||||
if (*string2 == '\0' || *string2 == '(')
|
||||
return 1;
|
||||
else
|
||||
return c1 - c2;
|
||||
else if (c1 > c2)
|
||||
return 1;
|
||||
else if (c1 < c2)
|
||||
return -1;
|
||||
/* PASSTHRU */
|
||||
}
|
||||
|
||||
if (case_pass == case_sensitive_on)
|
||||
return 0;
|
||||
|
||||
/* Otherwise the strings were equal in case insensitive way, make
|
||||
a more fine grained comparison in a case sensitive way. */
|
||||
|
||||
case_pass = case_sensitive_on;
|
||||
string1 = saved_string1;
|
||||
string2 = saved_string2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue