From: Matt Rice <ratmice@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Michael Snyder <msnyder@vmware.com>,
"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 13:12:00 -0000 [thread overview]
Message-ID: <AANLkTinCmHKyxq=LU28Sp==ijAWheSiYXkxyc85_h9yp@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=ugFjNKZdMAcxYnY23+=Ov8DjNvW1_27ejAEZE@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]
On Wed, Oct 6, 2010 at 3:03 AM, Matt Rice <ratmice@gmail.com> wrote:
> On Wed, Oct 6, 2010 at 1:51 AM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>> On Wed, 06 Oct 2010 04:30:33 +0200, Matt Rice wrote:
>>> 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?)
>>
>> Wouldn't be enough to replace the bitmask just by?
>> if (current_language->la_language == language_objc)
>
> objective-c uses mixed compilation units possibly more than most other
> languages,
<snip>
i could have argued this more concisely,
what I mean is that 'break' is not related to the current language,
but the language which we want to be the current language
when the breakpoint is hit. and so 'set language' to use language
specific breakpoints is arguably wrong because the current language
may not be the language of the breakpoint we want set.
>>> 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
>>
>> For current_language it works even without DW_LANG_ObjC due to:
>> init_filename_language_table (void)
>> add_filename_language (".m", language_objc);
>
> maybe the dwarf2read call to set_language_has_cu_loaded is redundant
> then since i added the call from set_language
>
doesn't seem as though reading language symfiles frobs the current
language afaict.
attached should fix GDB's pre-DW_LANG_ObjC, tested it with stabs,
don't have an old
enough compiler to test the others easily though.
attached calls set_language_has_cu_loaded when calling
deduce_language_from_filename.
except for the symtab case, i dont think we need it there since we
should already have called it
when making psytmabs. Thanks for the pointer.
for some reason i installed gnat/libgnat-devel but still not getting
ada testsuite :/
i'll get started looking at the new failures.
[-- Attachment #2: gdb-lang-objc.diff --]
[-- Type: application/octet-stream, Size: 8690 bytes --]
diff --git a/gdb/NEWS b/gdb/NEWS
index 85059c6..2369752 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.
+ 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/buildsym.c b/gdb/buildsym.c
index 4a76e3e..0c9186d 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -44,6 +44,7 @@
#include "cp-support.h"
#include "dictionary.h"
#include "addrmap.h"
+#include "language.h"
/* Ask buildsym.h to define the vars it normally declares `extern'. */
#define EXTERN
@@ -621,6 +622,9 @@ start_subfile (const char *name, const char *dirname)
{
subfile->language = subfile->next->language;
}
+
+ set_language_has_cu_loaded(subfile->language);
+
}
/* For stabs readers, the first N_SO symbol is assumed to be the
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index af94659..57e9b29 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -56,6 +56,7 @@
#include "cp-abi.h"
#include "cp-support.h"
#include "psympriv.h"
+#include "language.h"
#include "gdb_assert.h"
#include "gdb_string.h"
@@ -1564,6 +1565,7 @@ read_dbx_symtab (struct objfile *objfile)
namestring = set_namestring (objfile, &nlist);
tmp_language = deduce_language_from_filename (namestring);
+ set_language_has_cu_loaded (tmp_language);
/* Only change the psymtab's language if we've learned
something useful (eg. tmp_language is not language_unknown).
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? */
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 5ce5db2..3136940 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -58,6 +58,7 @@
#include "gdb_stat.h"
#include "gdb_string.h"
#include "psympriv.h"
+#include "language.h"
#include "bfd.h"
@@ -2700,6 +2701,9 @@ parse_partial_symbols (struct objfile *objfile)
psymtab_language = deduce_language_from_filename (fdr_name (fh));
break;
}
+
+ set_language_has_cu_loaded (psymtab_language);
+
if (psymtab_language == language_unknown)
psymtab_language = prev_language;
PST_PRIVATE (pst)->pst_language = psymtab_language;
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 902d48f..541ec22 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1973,6 +1973,7 @@ xcoff_start_psymtab (struct objfile *objfile, char *filename, int first_symnum,
/* Deduce the source language from the filename for this psymtab. */
psymtab_language = deduce_language_from_filename (filename);
+ set_language_has_cu_loaded (psymtab_language);
return result;
}
next prev parent reply other threads:[~2010-10-06 13:12 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
2010-10-06 8:51 ` Jan Kratochvil
2010-10-06 10:03 ` Matt Rice
2010-10-06 13:12 ` Matt Rice [this message]
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='AANLkTinCmHKyxq=LU28Sp==ijAWheSiYXkxyc85_h9yp@mail.gmail.com' \
--to=ratmice@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--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