From: Matt Rice <ratmice@gmail.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: gdb.objc/objcdecode.exp test error..
Date: Thu, 24 Sep 2009 22:29:00 -0000 [thread overview]
Message-ID: <8ba6bed40909241528m1e98f425k8792016b29179239@mail.gmail.com> (raw)
In-Reply-To: <8ba6bed40909240124u26f24397p39a1fd0d61462451@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1614 bytes --]
On Thu, Sep 24, 2009 at 1:24 AM, Matt Rice <ratmice@gmail.com> wrote:
> On Wed, Sep 23, 2009 at 5:53 PM, Joel Brobecker <brobecker@adacore.com> wrote:
>> This would not help handling the case of breakpoint expressions
>> leading to more than one location. For this, once we have determined
>> all possible matches, we need to be able to store their location in
>> a way that uniquely identifies them. Otherwise, we wouldn't be
>> able to "re_set" each one of them when running the program, or when
>> a new shared-library is loaded.
>
> It just occured to me that we could canonicalize these homonyms
> using '-[Foo() bar]' to mean method not in a category, and
> '-[Foo(categoryName) bar]', that also means extending decode_objc to
> accept -[Foo() bar] syntax I'm not sure if it will currently accept
> it.
ok, so this patch disambiguates the homonyms,
given a method with 2 implementations:
-[Foo bar] and -[Foo(aCategoryName) bar]
going 'break -[Foo bar]' will possibly create up to 2 breakpoints
-[Foo() bar], and -[Foo(aCategoryname) bar]
if we get better homonym support we can still refer to them both as a
single deal, using [Foo bar] syntax, but we can also refer to each
method individually.
I'll get working on the other part now, I see that the ada code uses
obsavestring in this, but i'm really not quite sure what its doing and
if it is possible to do this that in this fashion yet.
2009-09-24 Matt Rice <ratmice@gmail.com>
* symtab.c (symbol_natural_name): Call objc_decode_symbol.
* objc-lang.c (objc_decode_symbol): New function.
[-- Attachment #2: category.diff --]
[-- Type: application/octet-stream, Size: 3916 bytes --]
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 0e4fb71..b94c0af 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -244,22 +244,20 @@ objc_demangle (const char *mangled, int options)
xfree(demangled); /* not mangled name */
return NULL;
}
- if (cp[1] == '_') { /* easy case: no category name */
- *cp++ = ' '; /* replace two '_' with one ' ' */
- strcpy(cp, mangled + (cp - demangled) + 2);
- }
- else {
- *cp++ = '('; /* less easy case: category name */
- cp = strchr(cp, '_');
- if (!cp)
- {
- xfree(demangled); /* not mangled name */
- return NULL;
- }
- *cp++ = ')';
- *cp++ = ' '; /* overwriting 1st char of method name... */
- strcpy(cp, mangled + (cp - demangled)); /* get it back */
- }
+
+ /* We leave the parentheses when lacking a category name to
+ disambiguate when there is multiple versions of a method.
+ So that break [Foo bar] can return canonical results. */
+ *cp++ = '('; /* less easy case: category name */
+ cp = strchr(cp, '_');
+ if (!cp)
+ {
+ xfree(demangled); /* not mangled name */
+ return NULL;
+ }
+ *cp++ = ')';
+ *cp++ = ' '; /* overwriting 1st char of method name... */
+ strcpy(cp, mangled + (cp - demangled)); /* get it back */
while (*cp && *cp == '_')
cp++; /* skip any initial underbars in method name */
@@ -1702,11 +1700,9 @@ find_implementation_from_class (struct gdbarch *gdbarch,
struct objc_method meth_str;
read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
-#if 0
fprintf (stderr,
"checking method 0x%lx against selector 0x%lx\n",
meth_str.name, sel);
-#endif
if (meth_str.name == sel)
/* FIXME: hppa arch was doing a pointer dereference
@@ -1841,3 +1837,50 @@ _initialize_objc_lang (void)
{
objc_objfile_data = register_objfile_data ();
}
+
+char *
+objc_decode_symbol (const struct general_symbol_info *gsymbol)
+{
+ char ntype = '\0';
+ char *nclass = NULL;
+ char *ncategory = NULL;
+ char *nselector = NULL;
+
+ char **resultp =
+ (char **) &gsymbol->language_specific.cplus_specific.demangled_name;
+
+ if (*resultp == NULL)
+ {
+
+ parse_method (gsymbol->name, &ntype, &nclass, &ncategory, &nselector);
+
+ if (ncategory == NULL)
+ ncategory = "\0";
+ if (ntype && nclass && ncategory && nselector) {
+ size_t newlen;
+ struct objfile *objf;
+
+ newlen = sizeof(ntype) + strlen(nclass) + strlen (ncategory)
+ + strlen(nselector) + sizeof("[]()");
+
+ *resultp = xmalloc(newlen);
+ sprintf(*resultp, "%c[%s(%s) %s]", ntype, nclass, ncategory, nselector);
+
+// objf = gsymbol->obj_section->objfile;
+// *resultp = obsavestring (*resultp, newlen, &objf->objfile_obstack);
+ return *resultp;
+ }
+#if 0
+ if (*resultp == NULL)
+ {
+ char **slot = (char **) htab_find_slot (decoded_names_store,
+ decoded, INSERT);
+ if (*slot == NULL)
+ *slot = xstrdup (decoded);
+
+ *resultp = *slot;
+ }
+#endif
+ }
+ return gsymbol->name;
+}
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8d9d72c..f893155 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -632,9 +632,14 @@ symbol_natural_name (const struct general_symbol_info *gsymbol)
{
case language_cplus:
case language_java:
+ if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
+ return gsymbol->language_specific.cplus_specific.demangled_name;
+ break;
case language_objc:
if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
return gsymbol->language_specific.cplus_specific.demangled_name;
+ else
+ return objc_decode_symbol (gsymbol);
break;
case language_ada:
if (gsymbol->language_specific.cplus_specific.demangled_name != NULL)
next prev parent reply other threads:[~2009-09-24 22:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 1:31 Matt Rice
2009-03-06 17:33 ` Joel Brobecker
2009-03-06 19:13 ` Pedro Alves
2009-03-07 12:07 ` Matt Rice
2009-03-08 14:16 ` Matt Rice
2009-03-09 2:10 ` Matt Rice
2009-09-11 11:43 ` Matt Rice
2009-09-24 0:53 ` Joel Brobecker
2009-09-24 8:24 ` Matt Rice
2009-09-24 18:28 ` Tom Tromey
2009-09-24 22:07 ` Matt Rice
2009-09-24 22:29 ` Matt Rice [this message]
2009-09-24 22:51 ` Matt Rice
2009-09-25 4:03 ` Matt Rice
2009-10-13 0:44 ` Tom Tromey
2009-10-14 1:59 ` Joel Brobecker
2009-09-23 23:13 ` Joel Brobecker
2009-09-24 6:48 ` Matt Rice
2009-09-24 16:41 ` Joel Brobecker
2009-09-24 17:31 ` Joel Brobecker
2009-09-24 17:41 ` Joel Brobecker
2009-09-24 16:52 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8ba6bed40909241528m1e98f425k8792016b29179239@mail.gmail.com \
--to=ratmice@gmail.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox