From: Matt Rice <ratmice@gmail.com>
To: Michael Snyder <msnyder@vmware.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: disable objective-c stuff when theres no objective-c cu.
Date: Wed, 06 Oct 2010 02:30:00 -0000 [thread overview]
Message-ID: <AANLkTikYV-ix6tkRWc7aZtbgdbegJeejA8+DB0OR3QFY@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=sBN9DvBbrFxjmA-U30HhY7+yPmdWU5y1OFoTr@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3131 bytes --]
On Tue, Oct 5, 2010 at 4:35 PM, Matt Rice <ratmice@gmail.com> wrote:
> On Tue, Oct 5, 2010 at 4:31 PM, Michael Snyder <msnyder@vmware.com> wrote:
>> Matt Rice wrote:
>>>
>>> this makes it so that a flag is set if either an objective-c
>>> compilation unit is found,
>>> or the user goes 'set language objective-c' in the case where debug
>>> symbols are absent.
>>>
>>> 2010-10-05 Matt Rice <ratmice@gmail.com>
>>>
>>> * defs.h: Add comment.
>>> * dwarf2read.c (set_cu_language): Notice that a language has been
>>> seen.
>>> * language.c (set_language): Ditto.
>>> (mask_for_language, language_has_cu_loaded): New Functions.
>>> (set_language_has_cu_loaded): Ditto.
>>> * language.h: Declare new functions.
>>> * linespec.c (decode_line_1): Don't lookup objective-c methods
>>> unless objective-c has been seen.
>>
>> Hi Matt,
>>
>> Do you have a copyright assignment?
>
> Yeah, I do
>
> and I should have probably noted that this is a change of behaviour
> so its kind of an RFC, and I didn't think about stabs, so w/ this they
> probably require 'set language objective-c' 'set language auto' should
> restore the old behaviour
>
> waiting on the testsuite to run, but it looks like gdb.objc/nondebug.exp
> is going to require 'set language objective-c'.
>
attached is a new patch, the old one had some typos/pasteos in
comments, and i noticed
that we can lessen the impact by checking for is_objc_method, or for
objective-c compilation units. (is_objc_method doesn't neccesarily
affect future lookups should it call set_language_has_cu_loaded?)
added a NEWS entry which at least explains the current impact of the change.
which may or may not be acceptable.
I asked on the gnustep-dev list a while ago about removing this
feature all together, they weren't opposed to replacing it with a
different but similar feature,
so they're probably not opposed to keeping the feature but having to
manually enable it if it cannot be lazily enabled.
here is when gcc started to emit DW_LANG_ObjC, maybe we could fall
back to source files with the .m extension.
http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01515.html
another patch here which i'll look into tomorrow to see whatever
happened with it,
might be helpful in squaring out support for other debug info formats
also probably looking for .m sources.
http://sourceware.org/ml/gdb-patches/2004-08/msg00138.html
the impetus for this is that Objective-c matches normal c functions as methods,
so when you set a breakpoint on a c-function it tries to match it to
an objective-c method and churns through all the symbols, then finally
falls back to looking for a c function.
-PASS: gdb.cp/psmang.exp: break s::method2
+FAIL: gdb.cp/psmang.exp: break s::method2 (got interactive prompt)
-FAIL: gdb.threads/attachstop-mt.exp: attach1, post-gdb sanity check
of the sleeping state - Red Hat BZ 197584
+PASS: gdb.threads/attachstop-mt.exp: attach1, post-gdb sanity check
of the sleeping state - Red Hat BZ 197584
at least it broke even.
[-- Attachment #2: gdb-lang-objc.diff --]
[-- Type: application/octet-stream, Size: 6448 bytes --]
diff --git a/gdb/NEWS b/gdb/NEWS
index 85059c6..01b0a3c 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -23,6 +23,25 @@
feature requires proper debuginfo support from the compiler; it
was added to GCC 4.5.
+* Objective-C changes:
+
+ ** GDB Objective-C language support has changed so that lookups of
+ objective-c methods is now done if any of the following conditions is true:
+
+ * GDB has identified objective-c code as having been loaded.
+
+ * The user has specified an objective-c method explicitly in the form of
+ `break +[Class aMethod]' or `break -[Class aMethod]' as opposed to
+ the short form `break aMethod'.
+
+ * The user has called 'set language objective-c' at least once;
+ though it need not be the current language.
+
+ For GDB to identify an objective-c library debug symbols must be present
+ and contain language information. Users wanting to retain the old behaviour
+ can add `set language objective-c` followed by `set language auto' lines
+ to their .gdbinit file.
+
* GDB now has some support for using labels in the program's source in
linespecs. For instance, you can use "advance label" to continue
execution to a label.
diff --git a/gdb/defs.h b/gdb/defs.h
index 9e4800c..304d1c9 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -185,7 +185,9 @@ extern void quit (void);
/* Languages represented in the symbol table and elsewhere.
This should probably be in language.h, but since enum's can't
be forward declared to satisfy opaque references before their
- actual definition, needs to be here. */
+ actual definition, needs to be here.
+
+ When adding a tangible language also update language.c:mask_for_language */
enum language
{
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bf36e01..e0d4d52 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9646,6 +9646,7 @@ set_cu_language (unsigned int lang, struct dwarf2_cu *cu)
break;
}
cu->language_defn = language_def (cu->language);
+ set_language_has_cu_loaded (cu->language);
}
/* Return the named attribute or NULL if not there. */
diff --git a/gdb/language.c b/gdb/language.c
index 3ce08b5..cdc69c9 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -435,6 +435,7 @@ set_language (enum language lang)
if (languages[i]->la_language == lang)
{
current_language = languages[i];
+ set_language_has_cu_loaded(current_language->la_language);
set_type_range_case ();
break;
}
@@ -1060,6 +1061,82 @@ default_get_string (struct value *value, gdb_byte **buffer, int *length,
error (_("Getting a string is unsupported in this language."));
}
+
+/* A mask for languages that want to enable specific behaviours if (not when)
+ a compilation unit of that language has been loaded. */
+#define CU_LOADED_C_LANG_MASK 0x1 << 0
+#define CU_LOADED_CPLUS_LANG_MASK 0x1 << 1
+#define CU_LOADED_D_LANG_MASK 0x1 << 2
+#define CU_LOADED_OBJC_LANG_MASK 0x1 << 3
+#define CU_LOADED_JAVA_LANG_MASK 0x1 << 4
+#define CU_LOADED_FORTRAN_LANG_MASK 0x1 << 5
+#define CU_LOADED_M2_LANG_MASK 0x1 << 6
+#define CU_LOADED_ASM_LANG_MASK 0x1 << 7
+#define CU_LOADED_PASCAL_LANG_MASK 0x1 << 8
+#define CU_LOADED_ADA_LANG_MASK 0x1 << 9
+#define CU_LOADED_SCM_LANG_MASK 0x1 << 10
+
+static unsigned int cu_languages_loaded_mask;
+
+static unsigned int
+mask_for_language(enum language lang)
+{
+ unsigned int lang_mask;
+ switch(lang)
+ {
+ case language_c: /* C */
+ lang_mask = CU_LOADED_C_LANG_MASK;
+ break;
+ case language_cplus: /* C++ */
+ lang_mask = CU_LOADED_CPLUS_LANG_MASK;
+ break;
+ case language_d: /* D */
+ lang_mask = CU_LOADED_D_LANG_MASK;
+ break;
+ case language_objc: /* Objective-C */
+ lang_mask = CU_LOADED_OBJC_LANG_MASK;
+ break;
+ case language_java: /* Java */
+ lang_mask = CU_LOADED_JAVA_LANG_MASK;
+ break;
+ case language_fortran: /* Fortran */
+ lang_mask = CU_LOADED_FORTRAN_LANG_MASK;
+ break;
+ case language_m2: /* Modula-2 */
+ lang_mask = CU_LOADED_M2_LANG_MASK;
+ break;
+ case language_asm: /* Assembly language */
+ lang_mask = CU_LOADED_ASM_LANG_MASK;
+ break;
+ case language_pascal: /* Pascal */
+ lang_mask = CU_LOADED_PASCAL_LANG_MASK;
+ break;
+ case language_ada: /* Ada */
+ lang_mask = CU_LOADED_ADA_LANG_MASK;
+ break;
+ case language_scm: /* Guile Scheme*/
+ lang_mask = CU_LOADED_SCM_LANG_MASK;
+ break;
+ default:
+ return 0;
+ }
+ return lang_mask;
+}
+
+unsigned int
+language_has_cu_loaded (enum language lang)
+{
+ unsigned int lang_mask = mask_for_language (lang);
+ return cu_languages_loaded_mask & lang_mask;
+}
+
+void
+set_language_has_cu_loaded (enum language lang)
+{
+ unsigned int lang_mask = mask_for_language (lang);
+ cu_languages_loaded_mask |= lang_mask;
+}
+
/* Define the language that is no language. */
static int
diff --git a/gdb/language.h b/gdb/language.h
index aa0523b..6fde401 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -523,4 +523,12 @@ void default_get_string (struct value *value, gdb_byte **buffer, int *length,
void c_get_string (struct value *value, gdb_byte **buffer, int *length,
struct type **char_type, const char **charset);
+/* Returns non-zero if cu of the language type has been previously loaded. */
+unsigned int
+language_has_cu_loaded (enum language lang);
+
+/* Sets that a cu of the language type has been previously loaded. */
+void
+set_language_has_cu_loaded (enum language lang);
+
#endif /* defined (LANGUAGE_H) */
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 91c5b90..b74c997 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -771,14 +771,15 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
/* Check if the symbol could be an Objective-C selector. */
- {
- struct symtabs_and_lines values;
+ if (is_objc_method || language_has_cu_loaded(language_objc))
+ {
+ struct symtabs_and_lines values;
- values = decode_objc (argptr, funfirstline, NULL,
+ values = decode_objc (argptr, funfirstline, NULL,
canonical, saved_arg);
- if (values.sals != NULL)
- return values;
- }
+ if (values.sals != NULL)
+ return values;
+ }
/* Does it look like there actually were two parts? */
next prev parent reply other threads:[~2010-10-06 2:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 22:37 Matt Rice
2010-10-05 23:31 ` Michael Snyder
2010-10-05 23:35 ` Matt Rice
2010-10-06 2:30 ` Matt Rice [this message]
2010-10-06 8:51 ` Jan Kratochvil
2010-10-06 10:03 ` Matt Rice
2010-10-06 13:12 ` Matt Rice
2010-10-06 17:06 ` Joel Brobecker
2010-10-06 17:54 ` Matt Rice
2010-10-17 20:13 ` Jan Kratochvil
2010-10-17 21:57 ` Matt Rice
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=AANLkTikYV-ix6tkRWc7aZtbgdbegJeejA8+DB0OR3QFY@mail.gmail.com \
--to=ratmice@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@vmware.com \
/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