* symtab.c (lookup_symtab): Removed.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index 3b3bb54727d60f376a4cf9fc6305ef85f38431ee..237006f208ccaf847e66ec558faa88011dcf0a06 100644 (file)
@@ -79,8 +79,6 @@ static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
                                                     const char *, int,
                                                     namespace_enum);
 
-static struct symtab *lookup_symtab_1 (char *);
-
 static struct symbol *lookup_symbol_aux (const char *name, const
                                         struct block *block, const
                                         namespace_enum namespace, int
@@ -137,8 +135,8 @@ cplusplus_hint (char *name)
    psymtabs.  *If* there is no '/' in the name, a match after a '/'
    in the symtab filename will also work.  */
 
-static struct symtab *
-lookup_symtab_1 (char *name)
+struct symtab *
+lookup_symtab (const char *name)
 {
   register struct symtab *s;
   register struct partial_symtab *ps;
@@ -157,7 +155,7 @@ got_symtab:
   if (lbasename (name) == name)
     ALL_SYMTABS (objfile, s)
     {
-      if (FILENAME_CMP (basename (s->filename), name) == 0)
+      if (FILENAME_CMP (lbasename (s->filename), name) == 0)
        return s;
     }
 
@@ -188,48 +186,12 @@ got_symtab:
   goto got_symtab;
 }
 
-/* Lookup the symbol table of a source file named NAME.  Try a couple
-   of variations if the first lookup doesn't work.  */
-
-struct symtab *
-lookup_symtab (char *name)
-{
-  register struct symtab *s;
-#if 0
-  register char *copy;
-#endif
-
-  s = lookup_symtab_1 (name);
-  if (s)
-    return s;
-
-#if 0
-  /* This screws c-exp.y:yylex if there is both a type "tree" and a symtab
-     "tree.c".  */
-
-  /* If name not found as specified, see if adding ".c" helps.  */
-  /* Why is this?  Is it just a user convenience?  (If so, it's pretty
-     questionable in the presence of C++, FORTRAN, etc.).  It's not in
-     the GDB manual.  */
-
-  copy = (char *) alloca (strlen (name) + 3);
-  strcpy (copy, name);
-  strcat (copy, ".c");
-  s = lookup_symtab_1 (copy);
-  if (s)
-    return s;
-#endif /* 0 */
-
-  /* We didn't find anything; die.  */
-  return 0;
-}
-
 /* Lookup the partial symbol table of a source file named NAME.
    *If* there is no '/' in the name, a match after a '/'
    in the psymtab filename will also work.  */
 
 struct partial_symtab *
-lookup_partial_symtab (char *name)
+lookup_partial_symtab (const char *name)
 {
   register struct partial_symtab *pst;
   register struct objfile *objfile;
@@ -247,7 +209,7 @@ lookup_partial_symtab (char *name)
   if (lbasename (name) == name)
     ALL_PSYMTABS (objfile, pst)
     {
-      if (FILENAME_CMP (basename (pst->filename), name) == 0)
+      if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
        return (pst);
     }
 
@@ -1158,7 +1120,7 @@ find_main_psymtab (void)
 
   ALL_PSYMTABS (objfile, pst)
   {
-    if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
+    if (lookup_partial_symbol (pst, main_name (), 1, VAR_NAMESPACE))
       {
        return (pst);
       }
@@ -2276,7 +2238,7 @@ file_matches (char *file, char *files[], int nfiles)
     {
       for (i = 0; i < nfiles; i++)
        {
-         if (strcmp (files[i], basename (file)) == 0)
+         if (strcmp (files[i], lbasename (file)) == 0)
            return 1;
        }
     }
@@ -3167,7 +3129,7 @@ make_file_symbol_completion_list (char *text, char *word, char *srcfile)
     {
       /* Maybe they typed the file with leading directories, while the
         symbol tables record only its basename.  */
-      char *tail = basename (srcfile);
+      const char *tail = lbasename (srcfile);
 
       if (tail > srcfile)
        s = lookup_symtab (tail);
@@ -3272,7 +3234,7 @@ make_source_files_completion_list (char *text, char *word)
   int list_used = 0;
   size_t text_len = strlen (text);
   char **list = (char **) xmalloc (list_alloced * sizeof (char *));
-  char *base_name;
+  const char *base_name;
 
   list[0] = NULL;
 
@@ -3302,7 +3264,7 @@ make_source_files_completion_list (char *text, char *word)
             debug info records leading directories, but not the other
             way around.  This is what subroutines of breakpoint
             command do when they parse file names.  */
-         base_name = basename (s->filename);
+         base_name = lbasename (s->filename);
          if (base_name != s->filename
              && !filename_seen (base_name, 1, &first)
 #if HAVE_DOS_BASED_FILE_SYSTEM
@@ -3338,7 +3300,7 @@ make_source_files_completion_list (char *text, char *word)
            }
          else
            {
-             base_name = basename (ps->filename);
+             base_name = lbasename (ps->filename);
              if (base_name != ps->filename
                  && !filename_seen (base_name, 1, &first)
 #if HAVE_DOS_BASED_FILE_SYSTEM
@@ -3624,6 +3586,33 @@ decode_line_spec (char *string, int funfirstline)
   return sals;
 }
 
+/* Track MAIN */
+static char *name_of_main;
+
+void
+set_main_name (const char *name)
+{
+  if (name_of_main != NULL)
+    {
+      xfree (name_of_main);
+      name_of_main = NULL;
+    }
+  if (name != NULL)
+    {
+      name_of_main = xstrdup (name);
+    }
+}
+
+char *
+main_name (void)
+{
+  if (name_of_main != NULL)
+    return name_of_main;
+  else
+    return "main";
+}
+
+
 void
 _initialize_symtab (void)
 {
This page took 0.028071 seconds and 4 git commands to generate.