Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.56 diff -u -p -r1.56 linespec.c --- linespec.c 11 Feb 2004 18:04:14 -0000 1.56 +++ linespec.c 24 Feb 2004 15:54:21 -0000 @@ -96,8 +96,9 @@ static char *find_toplevel_char (char *s static int is_objc_method_format (const char *s); -static struct symtabs_and_lines decode_line_2 (struct symbol *[], - int, int, char ***); +static struct symtabs_and_lines decode_line_2 (struct symbol *[], int, + struct minimal_symbol *[], int, + int, char ***); static struct symtab *symtab_from_filename (char **argptr, char *p, int is_quote_enclosed, @@ -467,13 +468,16 @@ is_objc_method_format (const char *s) } /* Given a list of NELTS symbols in SYM_ARR, return a list of lines to - operate on (ask user if necessary). + operate on (ask user if necessary). After processing the symbols, + process the minimal_symbols as well (if any). This allows us to add + functions to the list from non-debugging modules. If CANONICAL is non-NULL return a corresponding array of mangled names as canonical line specs there. */ static struct symtabs_and_lines -decode_line_2 (struct symbol *sym_arr[], int nelts, int funfirstline, - char ***canonical) +decode_line_2 (struct symbol *sym_arr[], int nelts, + struct minimal_symbol *msym_arr[], int nmsym, + int funfirstline, char ***canonical) { struct symtabs_and_lines values, return_values; char *args, *arg1; @@ -484,9 +488,9 @@ decode_line_2 (struct symbol *sym_arr[], char **canonical_arr = (char **) NULL; values.sals = (struct symtab_and_line *) - alloca (nelts * sizeof (struct symtab_and_line)); + alloca ((nelts+nmsym) * sizeof (struct symtab_and_line)); return_values.sals = (struct symtab_and_line *) - xmalloc (nelts * sizeof (struct symtab_and_line)); + xmalloc ((nelts+nmsym) * sizeof (struct symtab_and_line)); old_chain = make_cleanup (xfree, return_values.sals); if (canonical) @@ -523,7 +527,21 @@ decode_line_2 (struct symbol *sym_arr[], printf_unfiltered ("?HERE\n"); i++; } - + + /* handle minimal_symbols */ + if (nmsym > 0) + printf_filtered ("\nNon-debugging symbols:\n"); + for (i = 0; i < nmsym; i++) + { + values.sals[nelts+i].symtab = 0; + values.sals[nelts+i].line = 0; + values.sals[nelts+i].end = 0; + values.sals[nelts+i].pc = SYMBOL_VALUE_ADDRESS (msym_arr[i]); + printf_filtered ("[%d] %s\n", + (nelts + i + 2), + SYMBOL_PRINT_NAME (msym_arr[i])); + } + prompt = getenv ("PS2"); if (prompt == NULL) { @@ -553,7 +571,7 @@ decode_line_2 (struct symbol *sym_arr[], { if (canonical_arr) { - for (i = 0; i < nelts; i++) + for (i = 0; i < (nelts+nmsym); i++) { if (canonical_arr[i] == NULL) { @@ -563,13 +581,13 @@ decode_line_2 (struct symbol *sym_arr[], } } memcpy (return_values.sals, values.sals, - (nelts * sizeof (struct symtab_and_line))); - return_values.nelts = nelts; + ((nelts+nmsym) * sizeof (struct symtab_and_line))); + return_values.nelts = (nelts+nmsym); discard_cleanups (old_chain); return return_values; } - if (num >= nelts + 2) + if (num >= (nelts+nmsym) + 2) { printf_unfiltered ("No choice number %d.\n", num); } @@ -1075,6 +1093,7 @@ decode_objc (char **argptr, int funfirst { struct symtabs_and_lines values; struct symbol **sym_arr = NULL; + struct minimal_symbol **msym_arr = NULL; struct symbol *sym = NULL; char *copy = NULL; struct block *block = NULL; @@ -1089,25 +1108,29 @@ decode_objc (char **argptr, int funfirst else block = get_selected_block (0); - copy = find_imps (file_symtab, block, *argptr, NULL, &i1, &i2); + copy = find_imps (file_symtab, block, *argptr, NULL, &i1, NULL, &i2); if (i1 > 0) { - sym_arr = (struct symbol **) alloca ((i1 + 1) * sizeof (struct symbol *)); + sym_arr = (struct symbol **) + alloca ((i1 + 1) * sizeof (struct symbol *)); sym_arr[i1] = 0; - - copy = find_imps (file_symtab, block, *argptr, sym_arr, &i1, &i2); + } + if (i2 > 0) + { + msym_arr = (struct minimal_symbol **) + alloca ((i2 + 1) * sizeof (struct minimal_symbol *)); + msym_arr[i2] = 0; + } + if (i1 > 0 || i2 > 0) + { + copy = find_imps (file_symtab, block, *argptr, sym_arr, &i1, msym_arr, &i2); *argptr = copy; } - /* i1 now represents the TOTAL number of matches found. - i2 represents how many HIGH-LEVEL (struct symbol) matches, - which will come first in the sym_arr array. Any low-level - (minimal_symbol) matches will follow those. */ - - if (i1 == 1) + if ((i1+i2) == 1) { - if (i2 > 0) + if (i1 > 0) { /* Already a struct symbol. */ sym = sym_arr[0]; @@ -1142,10 +1165,10 @@ decode_objc (char **argptr, int funfirst return values; } - if (i1 > 1) + if ((i1+i2) > 1) { /* More than one match. The user must choose one or more. */ - return decode_line_2 (sym_arr, i2, funfirstline, canonical); + return decode_line_2 (sym_arr, i1, msym_arr, i2, funfirstline, canonical); } return values; @@ -1433,7 +1456,7 @@ find_method (int funfirstline, char ***c { /* There is more than one field with that name (overloaded). Ask the user which one to use. */ - return decode_line_2 (sym_arr, i1, funfirstline, canonical); + return decode_line_2 (sym_arr, i1, NULL, 0, funfirstline, canonical); } else { Index: objc-lang.c =================================================================== RCS file: /cvs/src/src/gdb/objc-lang.c,v retrieving revision 1.34 diff -u -p -r1.34 objc-lang.c --- objc-lang.c 18 Feb 2004 04:22:35 -0000 1.34 +++ objc-lang.c 24 Feb 2004 15:54:22 -0000 @@ -1277,7 +1277,8 @@ static void find_methods (struct symtab *symtab, char type, const char *class, const char *category, const char *selector, struct symbol **syms, - unsigned int *nsym, unsigned int *ndebug) + unsigned int *ndebug, struct minimal_symbol **msyms, + unsigned int *nsym) { struct objfile *objfile = NULL; struct minimal_symbol *msymbol = NULL; @@ -1361,10 +1362,8 @@ find_methods (struct symtab *symtab, cha lower part of sym_arr (below num_debuggable). */ if (syms != NULL) { - syms[csym] = syms[cdebug]; syms[cdebug] = sym; } - csym++; cdebug++; } else @@ -1372,16 +1371,16 @@ find_methods (struct symtab *symtab, cha warning ( "debugging symbol \"%s\" does not match minimal symbol (\"%s\"); ignoring", newsymname, symname); - if (syms != NULL) - syms[csym] = (struct symbol *) msymbol; + if (msyms != NULL) + msyms[csym] = msymbol; csym++; } } else { /* Found a non-debuggable method symbol. */ - if (syms != NULL) - syms[csym] = (struct symbol *) msymbol; + if (msyms != NULL) + msyms[csym] = msymbol; csym++; } } @@ -1394,7 +1393,8 @@ find_methods (struct symtab *symtab, cha char *find_imps (struct symtab *symtab, struct block *block, char *method, struct symbol **syms, - unsigned int *nsym, unsigned int *ndebug) + unsigned int *ndebug, struct minimal_symbol **msyms, + unsigned int *nsym) { char type = '\0'; char *class = NULL; @@ -1437,8 +1437,7 @@ char *find_imps (struct symtab *symtab, if (sym != NULL) { if (syms) - syms[csym] = sym; - csym++; + syms[cdebug] = sym; cdebug++; } @@ -1447,51 +1446,23 @@ char *find_imps (struct symtab *symtab, if (msym != NULL) { - if (syms) - syms[csym] = (struct symbol *)msym; + if (msyms) + msyms[csym] = msym; csym++; } } - if (syms != NULL) + if (syms != NULL || msyms != NULL) find_methods (symtab, type, class, category, selector, - syms + csym, &ncsym, &ncdebug); + syms + cdebug, &ncdebug, msyms + csym, &ncsym); else find_methods (symtab, type, class, category, selector, - NULL, &ncsym, &ncdebug); + NULL, &ncdebug, NULL, &ncsym); /* If we didn't find any methods, just return. */ if (ncsym == 0 && ncdebug == 0) return method; - /* Take debug symbols from the second batch of symbols and swap them - * with debug symbols from the first batch. Repeat until either the - * second section is out of debug symbols or the first section is - * full of debug symbols. Either way we have all debug symbols - * packed to the beginning of the buffer. - */ - - if (syms != NULL) - { - while ((cdebug < csym) && (ncdebug > 0)) - { - struct symbol *s = NULL; - /* First non-debugging symbol. */ - unsigned int i = cdebug; - /* Last of second batch of debug symbols. */ - unsigned int j = csym + ncdebug - 1; - - s = syms[j]; - syms[j] = syms[i]; - syms[i] = s; - - /* We've moved a symbol from the second debug section to the - first one. */ - cdebug++; - ncdebug--; - } - } - csym += ncsym; cdebug += ncdebug; @@ -1500,23 +1471,20 @@ char *find_imps (struct symtab *symtab, if (ndebug != NULL) *ndebug = cdebug; - if (syms == NULL) + if (syms == NULL && msyms == NULL) return method + (tmp - buf); - if (csym > 1) - { - /* Sort debuggable symbols. */ - if (cdebug > 1) - qsort (syms, cdebug, sizeof (struct minimal_symbol *), - compare_classes); + /* Sort debuggable symbols. */ + if (cdebug > 1) + qsort (syms, cdebug, sizeof (struct minimal_symbol *), compare_classes); - /* Sort minimal_symbols. */ - if ((csym - cdebug) > 1) - qsort (&syms[cdebug], csym - cdebug, - sizeof (struct minimal_symbol *), compare_classes); - } - /* Terminate the sym_arr list. */ - syms[csym] = 0; + /* Sort minimal_symbols. */ + if (csym > 1) + qsort (msyms, csym, sizeof (struct minimal_symbol *), compare_classes); + + /* Terminate the sym_arr lists. */ + syms[cdebug] = 0; + msyms[csym] = 0; return method + (tmp - buf); } Index: objc-lang.h =================================================================== RCS file: /cvs/src/src/gdb/objc-lang.h,v retrieving revision 1.11 diff -u -p -r1.11 objc-lang.h --- objc-lang.h 18 Feb 2004 04:22:35 -0000 1.11 +++ objc-lang.h 24 Feb 2004 15:54:22 -0000 @@ -53,7 +53,8 @@ extern char *parse_method (char *method, extern char *find_imps (struct symtab *symtab, struct block *block, char *method, struct symbol **syms, - unsigned int *nsym, unsigned int *ndebug); + unsigned int *ndebug, struct minimal_symbol **msyms, + unsigned int *nsym); extern struct value *value_nsstring (char *ptr, int len);