From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 345 invoked by alias); 9 May 2003 17:03:36 -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 32736 invoked from network); 9 May 2003 17:03:35 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 9 May 2003 17:03:35 -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 h49H3ZH21697 for ; Fri, 9 May 2003 13:03:35 -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 h49H3ZI18903 for ; Fri, 9 May 2003 13:03:35 -0400 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h49H3Y813456 for ; Fri, 9 May 2003 13:03:34 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id 16A152C438; Fri, 9 May 2003 13:08:39 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16059.57494.905714.554627@localhost.redhat.com> Date: Fri, 09 May 2003 17:03:00 -0000 To: Adam Fedor Cc: GDB Patches Subject: Re: [PING/RFA]: Search for Objc Symbols In-Reply-To: <3EA9FF5A.2040209@doc.com> References: <3EA9FF5A.2040209@doc.com> X-SW-Source: 2003-05/txt/msg00133.txt.bz2 Adam Fedor writes: > I forgot about this one: > > http://sources.redhat.com/ml/gdb-patches/2003-01/msg00441.html > > It doesn't apprear that this was ever formally approved. I've attached > the patch again since there have been some minor changes since then in > order to keep up with the times... > > see below... > 2003-04-25 Adam Fedor > > * symtab.c (make_symbol_completion_list): Look for ObjC > symbols. > * Makefile.in (symtab.o): Update dependencies. > > Index: Makefile.in > =================================================================== > RCS file: /cvs/src/src/gdb/Makefile.in,v > retrieving revision 1.367 > diff -u -p -r1.367 Makefile.in > --- Makefile.in 26 Apr 2003 01:57:28 -0000 1.367 > +++ Makefile.in 26 Apr 2003 03:12:16 -0000 > @@ -2275,7 +2275,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h) > $(gdbcmd_h) $(call_cmds_h) $(gdb_regex_h) $(expression_h) \ > $(language_h) $(demangle_h) $(inferior_h) $(linespec_h) \ > $(filenames_h) $(gdb_obstack_h) $(gdb_string_h) $(gdb_stat_h) \ > - $(cp_abi_h) $(source_h) $(block_h) > + $(cp_abi_h) $(source_h) $(block_h) $(objc_lang_h) > target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \ > $(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \ > $(gdb_wait_h) $(dcache_h) $(regcache_h) > Index: symtab.c > =================================================================== > RCS file: /cvs/src/src/gdb/symtab.c,v > retrieving revision 1.101 > diff -u -p -r1.101 symtab.c > --- symtab.c 14 Apr 2003 19:56:32 -0000 1.101 > +++ symtab.c 26 Apr 2003 03:12:21 -0000 > @@ -40,6 +40,7 @@ > #include "linespec.h" > #include "source.h" > #include "filenames.h" /* for FILENAME_CMP */ > +#include "objc-lang.h" > > #include "hashtab.h" > > @@ -3527,10 +3541,69 @@ make_symbol_completion_list (char *text, > anything that isn't a text symbol (everything else will be > handled by the psymtab code above). */ > > + /* ObjC: In case we are completing on a selector, look thru the msymbols > + again and feed all the selectors into the mill. */ > + > ALL_MSYMBOLS (objfile, msymbol) > { > + static char *tmp = NULL; > + static unsigned int tmplen = 0; > + > + char *method, *category, *selector; > + char *tmp2 = NULL; > + > QUIT; > - COMPLETION_LIST_ADD_SYMBOL (msymbol, sym_text, sym_text_len, text, word); > + > + method = SYMBOL_DEMANGLED_NAME (msymbol); > + if (method == NULL) > + method = SYMBOL_LINKAGE_NAME (msymbol); > + if (method == NULL) > + continue; > + > + /* Add the minimal symbol no matter what. */ > + completion_list_add_name (method, sym_text, sym_text_len, text, word); > + this should not be needed, I think, i.e. the former macro invocation should still be ok. > + /* Is it a method? */ > + if ((method[0] != '-') && (method[0] != '+')) > + continue; > + 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); > + } Now that I look at this again, I think the code you are adding above could be easily split up into an objc specific function. Could you do that? > } > > /* Search upwards from currently selected frame (so that we can > @@ -3548,6 +3621,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) > { There is no changelog entry for this one below. > @@ -3653,15 +3727,45 @@ 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; > - } > + /* It is not a quoted string. Break it based on the characters > + which are in symbols. */ > + 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; > + } > + } Same here, could this be made into an objc specific function? > sym_text = p; > } > } elena