From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22400 invoked by alias); 12 May 2003 18:57:39 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8318 invoked from network); 12 May 2003 18:50:30 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 12 May 2003 18:50:30 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h4CIoUH13126 for ; Mon, 12 May 2003 14:50:30 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h4CIoUI02722 for ; Mon, 12 May 2003 14:50:30 -0400 Received: from localhost.redhat.com (IDENT:pjCSylp+A6MEDzUSLt+c+X+UL3jDf2iH@tooth.toronto.redhat.com [172.16.14.29]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h4CIoQA19076; Mon, 12 May 2003 14:50:26 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 9AC7F2C94F; Mon, 12 May 2003 14:55:36 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16063.60968.371306.846032@localhost.redhat.com> Date: Mon, 12 May 2003 18:57:00 -0000 To: Adam Fedor Cc: Elena Zannoni , GDB Patches Subject: Re: [PING/RFA]: Search for Objc Symbols In-Reply-To: <3EBDC3F7.6060201@doc.com> References: <3EA9FF5A.2040209@doc.com> <16059.57494.905714.554627@localhost.redhat.com> <3EBDC3F7.6060201@doc.com> X-SW-Source: 2003-05/txt/msg00187.txt.bz2 Adam Fedor writes: > I've broken out the changes into their own functions. Looking at the > comments in make_file_symbol_completion_list now, it seems like the > language_search_unquoted_string function or something similar should go > in the language vector. But I'm not sure that's necessary, so I didn't > want to do it unless some one made me :-) I think for now you can just add a FIXME to the functions and say that they should be integrated with the language vector. There are other things in the symbol table that could be pushed out because they are more language specific, but I want to think about it (especially with the namespace changes coming through). So, this can go in, if you address the concerns that DavidC expressed. Is this really it??? We have objc?? :-) elena > > 2003-05-10 Adam Fedor > > * symtab.c (completion_list_objc_symbol): New function. > (make_symbol_completion_list): Use it to add ObjC symbols > when looking though the list. > (language_search_unquoted_string): New function. > (make_file_symbol_completion_list): Use it. > > Index: symtab.c > =================================================================== > RCS file: /cvs/src/src/gdb/symtab.c,v > retrieving revision 1.102 > diff -u -p -r1.102 symtab.c > --- symtab.c 29 Apr 2003 02:34:24 -0000 1.102 > +++ symtab.c 11 May 2003 03:13:54 -0000 > @@ -3423,6 +3423,116 @@ completion_list_add_name (char *symname, > } > } > > +/* ObjC: In case we are completing on a selector, look as the msymbol > + again and feed all the selectors into the mill. */ > + > +static void > +completion_list_objc_symbol (struct minimal_symbol *msymbol, char *sym_text, > + int sym_text_len, char *text, char *word) > +{ > + static char *tmp = NULL; > + static unsigned int tmplen = 0; > + > + char *method, *category, *selector; > + char *tmp2 = NULL; > + > + method = SYMBOL_DEMANGLED_NAME (msymbol); > + if (method == NULL) > + method = SYMBOL_LINKAGE_NAME (msymbol); > + if (method == NULL) > + return; > + > + /* Is it a method? */ > + if ((method[0] != '-') && (method[0] != '+')) > + return; > + > + if (sym_text[0] == '[') > + /* Complete on shortened method method. */ > + completion_list_add_name (method + 1, sym_text, sym_text_len, text, word); > + > + while ((strlen (method) + 1) >= tmplen) > + { > + if (tmplen == 0) > + tmplen = 1024; > + else > + tmplen *= 2; > + tmp = xrealloc (tmp, tmplen); > + } > + selector = strchr (method, ' '); > + if (selector != NULL) > + selector++; > + > + category = strchr (method, '('); > + > + if ((category != NULL) && (selector != NULL)) > + { > + memcpy (tmp, method, (category - method)); > + tmp[category - method] = ' '; > + memcpy (tmp + (category - method) + 1, selector, strlen (selector) + 1); > + completion_list_add_name (tmp, sym_text, sym_text_len, text, word); > + if (sym_text[0] == '[') > + completion_list_add_name (tmp + 1, sym_text, sym_text_len, text, word); > + } > + > + if (selector != NULL) > + { > + /* Complete on selector only. */ > + strcpy (tmp, selector); > + tmp2 = strchr (tmp, ']'); > + if (tmp2 != NULL) > + *tmp2 = '\0'; > + > + completion_list_add_name (tmp, sym_text, sym_text_len, text, word); > + } > +} > + > +/* Break the non-quoted text based on the characters which are in > + symbols. */ > + > +static char * > +language_search_unquoted_string (char *text, char *p) > +{ > + for (; p > text; --p) > + { > + if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0') > + continue; > + else > + { > + if ((current_language->la_language == language_objc)) > + { > + if (p[-1] == ':') /* might be part of a method name */ > + continue; > + else if (p[-1] == '[' && (p[-2] == '-' || p[-2] == '+')) > + p -= 2; /* beginning of a method name */ > + else if (p[-1] == ' ' || p[-1] == '(' || p[-1] == ')') > + { /* might be part of a method name */ > + char *t = p; > + > + /* Seeing a ' ' or a '(' is not conclusive evidence > + that we are in the middle of a method name. However, > + finding "-[" or "+[" should be pretty un-ambiguous. > + Unfortunately we have to find it now to decide. */ > + > + while (t > text) > + if (isalnum (t[-1]) || t[-1] == '_' || > + t[-1] == ' ' || t[-1] == ':' || > + t[-1] == '(' || t[-1] == ')') > + --t; > + else > + break; > + > + if (t[-1] == '[' && (t[-2] == '-' || t[-2] == '+')) > + p = t - 2; /* method name detected */ > + /* else we leave with p unchanged */ > + } > + } > + break; > + } > + } > + return p; > +} > + > + > /* Return a NULL terminated array of all symbols (regardless of class) > which begin by matching TEXT. If the answer is no symbols, then > the return value is an array which contains only a NULL pointer. > @@ -3545,6 +3655,8 @@ make_symbol_completion_list (char *text, > { > QUIT; > COMPLETION_LIST_ADD_SYMBOL (msymbol, sym_text, sym_text_len, text, word); > + > + completion_list_objc_symbol (msymbol, sym_text, sym_text_len, text, word); > } > > /* Search upwards from currently selected frame (so that we can > @@ -3562,6 +3674,7 @@ make_symbol_completion_list (char *text, > > ALL_BLOCK_SYMBOLS (b, i, sym) > { > + QUIT; > COMPLETION_LIST_ADD_SYMBOL (sym, sym_text, sym_text_len, text, word); > if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) > { > @@ -3667,16 +3780,8 @@ make_file_symbol_completion_list (char * > } > else > { > - /* It is not a quoted string. Break it based on the characters > - which are in symbols. */ > - while (p > text) > - { > - if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0') > - --p; > - else > - break; > - } > - sym_text = p; > + /* Not a quoted string. */ > + sym_text = language_search_unquoted_string (text, p); > } > } >