Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matt Rice <ratmice@gmail.com>
To: gdb-patches@sourceware.org
Subject: disable objective-c stuff when theres no objective-c cu.
Date: Tue, 05 Oct 2010 22:37:00 -0000	[thread overview]
Message-ID: <AANLkTin2HJp4ViQ22Q9GKKDS36DBSrzbdJ-0GKPBKreM@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 655 bytes --]

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.

[-- Attachment #2: gdb-lang-objc.diff --]
[-- Type: application/octet-stream, Size: 5286 bytes --]

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..2a8c727 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,83 @@ default_get_string (struct value *value, gdb_byte **buffer, int *length,
   error (_("Getting a string is unsupported in this language."));
 }
 
+
+/* A mask for langauges that want to enable specific behaviours if (not when) 
+   a compilation unit of that language has been loaded. the only one currently
+   in use is objc but i figured its best to make it a generic api */
+#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:		/* Pascal */
+        lang_mask = CU_LOADED_ADA_LANG_MASK;
+      break;
+      case language_scm:		/* Pascal */
+        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..4c7197f 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 (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?  */
 

             reply	other threads:[~2010-10-05 22:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05 22:37 Matt Rice [this message]
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
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=AANLkTin2HJp4ViQ22Q9GKKDS36DBSrzbdJ-0GKPBKreM@mail.gmail.com \
    --to=ratmice@gmail.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