This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfa/sym*] Look at N_MAIN


(resolving this is part of the 5.1 release criteria)

The attatched patch gets GDB to make use of N_MAIN when available.  The
original, submitted by Anthony Green, needed some improvements (see
attatched e-mails).

I've addressed just the memory leak problem.

	Andrew
2001-03-16  Andrew Cagney  <ac131313@redhat.com>

	* symtab.c (main_name): New function.
	(set_main_name): New function.
	* symtab.h: Declare.

	From 2000-03-05 Anthony Green <green@redhat.com>:
	* dbxread.c (process_one_symbol): Handle the N_MAIN stab by
	setting main_name.
	* blockframe.c (inside_main_func): Use main_name instead of
	"main".
	* symtab.c (find_main_psymtab): Ditto.
	* source.c (select_source_symtab): Ditto.
	* nlmread.c (nlm_symfile_read): Ditto.
	* rs6000-tdep.c (skip_prologue): Ditto.

Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.13
diff -p -r1.13 blockframe.c
*** blockframe.c	2001/03/06 08:21:05	1.13
--- blockframe.c	2001/03/16 15:35:39
*************** inside_main_func (CORE_ADDR pc)
*** 120,126 ****
      {
        struct symbol *mainsym;
  
!       mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
        if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
  	{
  	  symfile_objfile->ei.main_func_lowpc =
--- 120,126 ----
      {
        struct symbol *mainsym;
  
!       mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL);
        if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
  	{
  	  symfile_objfile->ei.main_func_lowpc =
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.15
diff -p -r1.15 dbxread.c
*** dbxread.c	2001/03/07 02:57:08	1.15
--- dbxread.c	2001/03/16 15:35:40
*************** process_one_symbol (int type, int desc, 
*** 2389,2401 ****
  	}
        break;
  
        /* The following symbol types can be ignored.  */
      case N_OBJ:		/* Solaris 2:  Object file dir and name */
        /*   N_UNDF:                   Solaris 2:  file separator mark */
        /*   N_UNDF: -- we will never encounter it, since we only process one
           file's symbols at once.  */
      case N_ENDM:		/* Solaris 2:  End of module */
-     case N_MAIN:		/* Name of main routine.  */
      case N_ALIAS:		/* SunPro F77: alias name, ignore for now.  */
        break;
      }
--- 2389,2405 ----
  	}
        break;
  
+     case N_MAIN:		/* Name of main routine.  */
+       if (name)
+ 	set_main_name (name);
+       break;
+ 
        /* The following symbol types can be ignored.  */
      case N_OBJ:		/* Solaris 2:  Object file dir and name */
        /*   N_UNDF:                   Solaris 2:  file separator mark */
        /*   N_UNDF: -- we will never encounter it, since we only process one
           file's symbols at once.  */
      case N_ENDM:		/* Solaris 2:  End of module */
      case N_ALIAS:		/* SunPro F77: alias name, ignore for now.  */
        break;
      }
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.43
diff -p -r1.43 defs.h
*** defs.h	2001/03/14 16:42:29	1.43
--- defs.h	2001/03/16 15:35:40
*************** enum gdb_rc gdb_list_thread_ids (/* outp
*** 1300,1303 ****
--- 1300,1304 ----
  
  /* Switch thread and print notification. */
  #endif
+ 
  #endif /* #ifndef DEFS_H */
Index: nlmread.c
===================================================================
RCS file: /cvs/src/src/gdb/nlmread.c,v
retrieving revision 1.7
diff -p -r1.7 nlmread.c
*** nlmread.c	2001/03/07 02:57:08	1.7
--- nlmread.c	2001/03/16 15:35:40
*************** nlm_symfile_read (struct objfile *objfil
*** 193,199 ****
    stabsect_build_psymtabs (objfile, mainline, ".stab",
  			   ".stabstr", ".text");
  
!   mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
  
    if (mainsym
        && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
--- 193,199 ----
    stabsect_build_psymtabs (objfile, mainline, ".stab",
  			   ".stabstr", ".text");
  
!   mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL);
  
    if (mainsym
        && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.20
diff -p -r1.20 rs6000-tdep.c
*** rs6000-tdep.c	2001/03/06 08:21:16	1.20
--- rs6000-tdep.c	2001/03/16 15:35:41
*************** skip_prologue (CORE_ADDR pc, CORE_ADDR l
*** 752,758 ****
  	     function as well. */
  
  	  tmp = find_pc_misc_function (pc);
! 	  if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main"))
  	    return pc + 8;
  	}
      }
--- 752,758 ----
  	     function as well. */
  
  	  tmp = find_pc_misc_function (pc);
! 	  if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name ()))
  	    return pc + 8;
  	}
      }
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.10
diff -p -r1.10 source.c
*** source.c	2001/03/06 08:21:17	1.10
--- source.c	2001/03/16 15:35:41
*************** select_source_symtab (register struct sy
*** 153,161 ****
  
    /* Make the default place to list be the function `main'
       if one exists.  */
!   if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL))
      {
!       sals = decode_line_spec ("main", 1);
        sal = sals.sals[0];
        xfree (sals.sals);
        current_source_symtab = sal.symtab;
--- 153,161 ----
  
    /* Make the default place to list be the function `main'
       if one exists.  */
!   if (lookup_symbol (main_name (), 0, VAR_NAMESPACE, 0, NULL))
      {
!       sals = decode_line_spec (main_name (), 1);
        sal = sals.sals[0];
        xfree (sals.sals);
        current_source_symtab = sal.symtab;
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.32
diff -p -r1.32 symtab.c
*** symtab.c	2001/03/06 08:21:17	1.32
--- symtab.c	2001/03/16 15:35:42
*************** find_main_psymtab (void)
*** 1174,1180 ****
  
    ALL_PSYMTABS (objfile, pst)
    {
!     if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
        {
  	return (pst);
        }
--- 1174,1180 ----
  
    ALL_PSYMTABS (objfile, pst)
    {
!     if (lookup_partial_symbol (pst, main_name (), 1, VAR_NAMESPACE))
        {
  	return (pst);
        }
*************** decode_line_spec (char *string, int funf
*** 3351,3356 ****
--- 3351,3383 ----
      error ("Junk at end of line specification: %s", string);
    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)
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.20
diff -p -r1.20 symtab.h
*** symtab.h	2001/03/07 02:57:08	1.20
--- symtab.h	2001/03/16 15:35:59
*************** extern void search_symbols (char *, name
*** 1447,1450 ****
--- 1447,1457 ----
  extern void free_search_symbols (struct symbol_search *);
  extern struct cleanup *make_cleanup_free_search_symbols (struct symbol_search *);
  
+ /* The name of the ``main'' function.
+    FIXME: cagney/2001-03-20: Can't make main_name() const since some
+    of the calling code currently assumes that the string isn't
+    const. */
+ extern void set_main_name (const char *name);
+ extern /*const*/ char *main_name (void);
+ 
  #endif /* !defined(SYMTAB_H) */



The java programming language doesn't have the same notion of "main"
that C and C++ do.  Any class can have a static main method.

Gcj lets you specify which main you want at link time with the --main=
option.  The compiler driver generates a little C source with a proper
"main", which simply calls java runtime initialization code, and
invokes the user's main.  Unfortunately, this is a pain when
debugging....

[green@adsl-63-195-83-169 /tmp]$ ~/java/net/gdb/b/gdb/gdb h
GNU gdb 20000204
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) list
2     /tmp/ccv1saFNmain.i: No such file or directory.


/tmp/ccv1saFNmain.i was the temporary source file created by the
compiler driver with the C "main" in it.


What we really want is 

[green@adsl-63-195-83-169 /tmp]$ ~/java/net/gdb/b/gdb/gdb h
GNU gdb 20000204
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) list
1	public class h
2	{
3	public static void main (String[] args)
4	{
5	  int x = 5;
6	  boolean b1 = true;
7	  boolean b2 = false;
8	  System.out.println ("Hello");
9	}
10	}


Jim Blandy once pointed out that there's a stab for this: N_MAIN.

Gdb currently ignores N_MAIN.  The following patch is an attempt to
make it understand N_MAIN.  IIRC, Insight puts a break at main on
startup.  It will also need a patch.

I tested this change with a simple change to the gcj compiler driver
(jvgenmain actually), and it appears to work.

2000-03-05  Anthony Green  <green@redhat.com>

	* defs.h (main_name): Declare.
	* dbxread.c (process_one_symbol): Handle the N_MAIN stab by
	setting main_name.
	* blockframe.c (inside_main_func): Use main_name instead of
	"main".
	* symtab.c (find_main_psymtab): Ditto.
	* source.c (select_source_symtab): Ditto.
	* nlmread.c (nlm_symfile_read): Ditto.
	* rs6000-tdep.c (skip_prologue): Ditto.


Index: gdb//blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.1.1.11
diff -p -r1.1.1.11 blockframe.c
*** blockframe.c	1999/12/22 21:45:03	1.1.1.11
--- blockframe.c	2000/03/05 10:20:27
*************** inside_main_func (pc)
*** 127,133 ****
      {
        struct symbol *mainsym;
  
!       mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
        if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
  	{
  	  symfile_objfile->ei.main_func_lowpc =
--- 127,133 ----
      {
        struct symbol *mainsym;
  
!       mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
        if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
  	{
  	  symfile_objfile->ei.main_func_lowpc =
Index: gdb//dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.1.1.10
diff -p -r1.1.1.10 dbxread.c
*** dbxread.c	2000/01/06 03:06:36	1.1.1.10
--- dbxread.c	2000/03/05 10:20:29
*************** process_one_symbol (type, desc, valu, na
*** 2426,2438 ****
  	}
        break;
  
        /* The following symbol types can be ignored.  */
      case N_OBJ:		/* Solaris 2:  Object file dir and name */
        /*   N_UNDF:                   Solaris 2:  file separator mark */
        /*   N_UNDF: -- we will never encounter it, since we only process one
           file's symbols at once.  */
      case N_ENDM:		/* Solaris 2:  End of module */
-     case N_MAIN:		/* Name of main routine.  */
      case N_ALIAS:		/* SunPro F77: alias name, ignore for now.  */
        break;
      }
--- 2426,2442 ----
  	}
        break;
  
+     case N_MAIN:		/* Name of main routine.  */
+       if (name)
+ 	main_name = xstrdup (name);
+       break;
+ 
        /* The following symbol types can be ignored.  */
      case N_OBJ:		/* Solaris 2:  Object file dir and name */
        /*   N_UNDF:                   Solaris 2:  file separator mark */
        /*   N_UNDF: -- we will never encounter it, since we only process one
           file's symbols at once.  */
      case N_ENDM:		/* Solaris 2:  End of module */
      case N_ALIAS:		/* SunPro F77: alias name, ignore for now.  */
        break;
      }
Index: gdb//defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.9
diff -p -r1.9 defs.h
*** defs.h	2000/03/04 02:23:06	1.9
--- defs.h	2000/03/05 10:20:30
*************** enum gdb_rc gdb_list_thread_ids (/* outp
*** 1314,1317 ****
--- 1314,1321 ----
  
  /* Switch thread and print notification. */
  #endif
+ 
+ /* From source.c  */
+ extern char *main_name;
+ 
  #endif /* #ifndef DEFS_H */
Index: gdb//nlmread.c
===================================================================
RCS file: /cvs/src/src/gdb/nlmread.c,v
retrieving revision 1.1.1.4
diff -p -r1.1.1.4 nlmread.c
*** nlmread.c	1999/08/09 21:33:43	1.1.1.4
--- nlmread.c	2000/03/05 10:20:31
*************** nlm_symfile_read (objfile, mainline)
*** 206,212 ****
    stabsect_build_psymtabs (objfile, mainline, ".stab",
  			   ".stabstr", ".text");
  
!   mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
  
    if (mainsym
        && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
--- 206,212 ----
    stabsect_build_psymtabs (objfile, mainline, ".stab",
  			   ".stabstr", ".text");
  
!   mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
  
    if (mainsym
        && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
Index: gdb//rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.5
diff -p -r1.5 rs6000-tdep.c
*** rs6000-tdep.c	2000/02/26 09:30:30	1.5
--- rs6000-tdep.c	2000/03/05 10:20:32
*************** skip_prologue (CORE_ADDR pc, struct rs60
*** 573,579 ****
  	     function as well. */
  
  	  tmp = find_pc_misc_function (pc);
! 	  if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main"))
  	    return pc + 8;
  	}
      }
--- 573,579 ----
  	     function as well. */
  
  	  tmp = find_pc_misc_function (pc);
! 	  if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name))
  	    return pc + 8;
  	}
      }
Index: gdb//source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.1.1.12
diff -p -r1.1.1.12 source.c
*** source.c	2000/02/03 04:14:35	1.1.1.12
--- source.c	2000/03/05 10:20:35
*************** static int first_line_listed;
*** 119,124 ****
--- 119,127 ----
  
  static struct symtab *last_source_visited = NULL;
  static int last_source_error = 0;
+ 
+ /* The default "main" symbol.  */
+ char *main_name = "main";
  
  
  /* Set the source file default for the "list" command to be S.
*************** select_source_symtab (s)
*** 151,159 ****
  
    /* Make the default place to list be the function `main'
       if one exists.  */
!   if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL))
      {
!       sals = decode_line_spec ("main", 1);
        sal = sals.sals[0];
        free (sals.sals);
        current_source_symtab = sal.symtab;
--- 154,162 ----
  
    /* Make the default place to list be the function `main'
       if one exists.  */
!   if (lookup_symbol (main_name, 0, VAR_NAMESPACE, 0, NULL))
      {
!       sals = decode_line_spec (main_name, 1);
        sal = sals.sals[0];
        free (sals.sals);
        current_source_symtab = sal.symtab;
Index: gdb//symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.2
diff -p -r1.2 symtab.c
*** symtab.c	2000/02/08 04:39:02	1.2
--- symtab.c	2000/03/05 10:20:37
*************** find_main_psymtab ()
*** 1172,1178 ****
  
    ALL_PSYMTABS (objfile, pst)
    {
!     if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
        {
  	return (pst);
        }
--- 1172,1178 ----
  
    ALL_PSYMTABS (objfile, pst)
    {
!     if (lookup_partial_symbol (pst, main_name, 1, VAR_NAMESPACE))
        {
  	return (pst);
        }

-- 
Anthony Green                                                        Red Hat
                                                       Sunnyvale, California






> Gdb currently ignores N_MAIN.  The following patch is an attempt to
> make it understand N_MAIN.

I looked over that patch and the basic concept looks fine.  N_MAIN is
already documented in doc/stabs.texinfo.

The patch does leak memory every time symbols are reloaded, though (a
bad thing in and of itself and also a hassle is using memory leak
detecting programs).  And probably has subtler bugs if one has a
symbol file with N_MAIN and then replaces it with a symbol file with
"main" and without N_MAIN.  I'm not sure exactly what rule to follow
but probably something like:

* N_MAIN takes precedence over "main" no matter what objfile it is in

* If there is more than one N_MAIN, choose the one in the
  symfile_objfile

* If there is more than one N_MAIN within a given objfile, complain()
  and choose arbitrarily.

I have no particularly strong objection if the maintainer (JimB, looks
like) wants to relegate the above to FIXME comments or something, but
I guess if you want my advice, it should be fairly easy to fix at
least the memory leak now.






FYI,

I think this patch slipped into limbo as it tweeks a number of files.

I believe JimK identified a memory leak.
For my part, I'd suggest ``main_name ()'' (or what ever) in symtab.[hc]
or source.h (anyway somewhere more applicable then defs.h which as
enough fluff :-).

	enjoy,
		Andrew


> 2000-03-05  Anthony Green  <green@redhat.com>
> 
>         * defs.h (main_name): Declare.
>         * dbxread.c (process_one_symbol): Handle the N_MAIN stab by
>         setting main_name.
>         * blockframe.c (inside_main_func): Use main_name instead of
>         "main".
>         * symtab.c (find_main_psymtab): Ditto.
>         * source.c (select_source_symtab): Ditto.
>         * nlmread.c (nlm_symfile_read): Ditto.
>         * rs6000-tdep.c (skip_prologue): Ditto.
> 
> Index: gdb//blockframe.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/blockframe.c,v
> retrieving revision 1.1.1.11
> diff -p -r1.1.1.11 blockframe.c
> *** blockframe.c        1999/12/22 21:45:03     1.1.1.11
> --- blockframe.c        2000/03/05 10:20:27
> *************** inside_main_func (pc)
> *** 127,133 ****
>       {
>         struct symbol *mainsym;
> 
> !       mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
>         if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
>         {
>           symfile_objfile->ei.main_func_lowpc =
> --- 127,133 ----
>       {
>         struct symbol *mainsym;
> 
> !       mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
>         if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
>         {
>           symfile_objfile->ei.main_func_lowpc =
> Index: gdb//dbxread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dbxread.c,v
> retrieving revision 1.1.1.10
> diff -p -r1.1.1.10 dbxread.c
> *** dbxread.c   2000/01/06 03:06:36     1.1.1.10
> --- dbxread.c   2000/03/05 10:20:29
> *************** process_one_symbol (type, desc, valu, na
> *** 2426,2438 ****
>         }
>         break;
> 
>         /* The following symbol types can be ignored.  */
>       case N_OBJ:               /* Solaris 2:  Object file dir and name */
>         /*   N_UNDF:                   Solaris 2:  file separator mark */
>         /*   N_UNDF: -- we will never encounter it, since we only process one
>            file's symbols at once.  */
>       case N_ENDM:              /* Solaris 2:  End of module */
> -     case N_MAIN:              /* Name of main routine.  */
>       case N_ALIAS:             /* SunPro F77: alias name, ignore for now.  */
>         break;
>       }
> --- 2426,2442 ----
>         }
>         break;
> 
> +     case N_MAIN:              /* Name of main routine.  */
> +       if (name)
> +       main_name = xstrdup (name);
> +       break;
> +
>         /* The following symbol types can be ignored.  */
>       case N_OBJ:               /* Solaris 2:  Object file dir and name */
>         /*   N_UNDF:                   Solaris 2:  file separator mark */
>         /*   N_UNDF: -- we will never encounter it, since we only process one
>            file's symbols at once.  */
>       case N_ENDM:              /* Solaris 2:  End of module */
>       case N_ALIAS:             /* SunPro F77: alias name, ignore for now.  */
>         break;
>       }
> Index: gdb//defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/defs.h,v
> retrieving revision 1.9
> diff -p -r1.9 defs.h
> *** defs.h      2000/03/04 02:23:06     1.9
> --- defs.h      2000/03/05 10:20:30
> *************** enum gdb_rc gdb_list_thread_ids (/* outp
> *** 1314,1317 ****
> --- 1314,1321 ----
> 
>   /* Switch thread and print notification. */
>   #endif
> +
> + /* From source.c  */
> + extern char *main_name;
> +
>   #endif /* #ifndef DEFS_H */
> Index: gdb//nlmread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/nlmread.c,v
> retrieving revision 1.1.1.4
> diff -p -r1.1.1.4 nlmread.c
> *** nlmread.c   1999/08/09 21:33:43     1.1.1.4
> --- nlmread.c   2000/03/05 10:20:31
> *************** nlm_symfile_read (objfile, mainline)
> *** 206,212 ****
>     stabsect_build_psymtabs (objfile, mainline, ".stab",
>                            ".stabstr", ".text");
> 
> !   mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL);
> 
>     if (mainsym
>         && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> --- 206,212 ----
>     stabsect_build_psymtabs (objfile, mainline, ".stab",
>                            ".stabstr", ".text");
> 
> !   mainsym = lookup_symbol (main_name, NULL, VAR_NAMESPACE, NULL, NULL);
> 
>     if (mainsym
>         && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
> Index: gdb//rs6000-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
> retrieving revision 1.5
> diff -p -r1.5 rs6000-tdep.c
> *** rs6000-tdep.c       2000/02/26 09:30:30     1.5
> --- rs6000-tdep.c       2000/03/05 10:20:32
> *************** skip_prologue (CORE_ADDR pc, struct rs60
> *** 573,579 ****
>              function as well. */
> 
>           tmp = find_pc_misc_function (pc);
> !         if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, "main"))
>             return pc + 8;
>         }
>       }
> --- 573,579 ----
>              function as well. */
> 
>           tmp = find_pc_misc_function (pc);
> !         if (tmp >= 0 && STREQ (misc_function_vector[tmp].name, main_name))
>             return pc + 8;
>         }
>       }
> Index: gdb//source.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/source.c,v
> retrieving revision 1.1.1.12
> diff -p -r1.1.1.12 source.c
> *** source.c    2000/02/03 04:14:35     1.1.1.12
> --- source.c    2000/03/05 10:20:35
> *************** static int first_line_listed;
> *** 119,124 ****
> --- 119,127 ----
> 
>   static struct symtab *last_source_visited = NULL;
>   static int last_source_error = 0;
> +
> + /* The default "main" symbol.  */
> + char *main_name = "main";
> 
> 
>   /* Set the source file default for the "list" command to be S.
> *************** select_source_symtab (s)
> *** 151,159 ****
> 
>     /* Make the default place to list be the function `main'
>        if one exists.  */
> !   if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL))
>       {
> !       sals = decode_line_spec ("main", 1);
>         sal = sals.sals[0];
>         free (sals.sals);
>         current_source_symtab = sal.symtab;
> --- 154,162 ----
> 
>     /* Make the default place to list be the function `main'
>        if one exists.  */
> !   if (lookup_symbol (main_name, 0, VAR_NAMESPACE, 0, NULL))
>       {
> !       sals = decode_line_spec (main_name, 1);
>         sal = sals.sals[0];
>         free (sals.sals);
>         current_source_symtab = sal.symtab;
> Index: gdb//symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.2
> diff -p -r1.2 symtab.c
> *** symtab.c    2000/02/08 04:39:02     1.2
> --- symtab.c    2000/03/05 10:20:37
> *************** find_main_psymtab ()
> *** 1172,1178 ****
> 
>     ALL_PSYMTABS (objfile, pst)
>     {
> !     if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
>         {
>         return (pst);
>         }
> --- 1172,1178 ----
> 
>     ALL_PSYMTABS (objfile, pst)
>     {
> !     if (lookup_partial_symbol (pst, main_name, 1, VAR_NAMESPACE))
>         {
>         return (pst);
>         }
> 
> --
> Anthony Green                                                        Red Hat
>                                                        Sunnyvale, California





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]