RFA: [symfile.c} Fix to symbol_file_add() [REPOST]

Fernando Nasser
2001-05-02T08:55:00Z

After the fruitful discussions with Elena, I believe I have a better
patch, so please consider this one instead.

As Elena explained, we must let the callers of symbol_file_add() do the
cache reset as we may be loading several shared libraries. Doing the
cache reset for each one is too much overhead as we will have to grab
the data for filling the current frame every single time. Well,
symbol_file_add_main () is a caller, so I guess it can go there. And
none of its callers has a a call to reinit_frame_cache() as they used to
call symbol_file_command().

I guess the previous behavior is being safely restored now.

However, several of the callers of symbol_file_add() do not call
reinit_frame_cache() as they should. But as far as I can tell, this has
always been like that. The only thing that is lost is the possibility
to get a better frame description of the current stack by using the
newly read symbols. I don't know enough about all this targets to know
if this is important (I don't know why they are reading symbol files).
The shared library case is already taken care of as Elena has pointed
out.

ChangeLog:

* symfile.c (symbol_file_command): Move cleanup operations
from here...
(symbol_file_add_main): ...to here, so they are run every time
a new main symbol file is read.

--
Fernando Nasser
Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario M4P 2C9
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.31
diff -c -p -r1.31 symfile.c
*** symfile.c 2001/04/05 02:02:13 1.31
--- symfile.c 2001/05/02 15:35:32
*************** symbol_file_add (char *name, int from_tt
*** 896,908 ****
return (objfile);
}

! /* Just call the above with default values.
! Used when the file is supplied in the gdb command line. */

void
symbol_file_add_main (char *args, int from_tty)
{
symbol_file_add (args, from_tty, NULL, 1, 0);
}

void
--- 896,920 ----
return (objfile);
}

! /* Call the above with default values and update whatever is
! affected by a new main().
! Used when the file is supplied in the gdb command line
! and by some targets. */

void
symbol_file_add_main (char *args, int from_tty)
{
symbol_file_add (args, from_tty, NULL, 1, 0);
+
+ #ifdef HPUXHPPA
+ RESET_HP_UX_GLOBALS ();
+ #endif
+
+ /* Getting new symbols may change our opinion about
+ what is frameless. */
+ reinit_frame_cache ();
+
+ set_initial_language ();
}

void
*************** symbol_file_command (char *args, int fro
*** 980,993 ****
{
name = *argv;
symbol_file_add (name, from_tty, NULL, 1, flags);
- #ifdef HPUXHPPA
- RESET_HP_UX_GLOBALS ();
- #endif
- /* Getting new symbols may change our opinion about
- what is frameless. */
- reinit_frame_cache ();
-
- set_initial_language ();
}
argv++;
}
--- 992,997 ----
From ezannoni@cygnus.com Wed May 02 09:06:00 2001
From: Elena Zannoni <ezannoni@cygnus.com>
To: Fernando Nasser <fnasser@redhat.com>
Cc: Elena Zannoni <ezannoni@cygnus.com>, gdb-patches@sources.redhat.com, hilfingr@otisco.mckusick.com
Subject: Re: RFA: [symfile.c} Fix to symbol_file_add() [REPOST]
Date: Wed, 02 May 2001 09:06:00 -0000
Message-id: <15088.12423.711167.908434@kwikemart.cygnus.com>
References: <3AED8391.C6B9A456@redhat.com> <15085.43538.55216.581538@kwikemart.cygnus.com> <3AEDF6A3.440D0C62@redhat.com> <15086.11696.278572.217415@kwikemart.cygnus.com> <3AEEB0E2.3232D2DE@redhat.com> <15087.31793.429533.289522@kwikemart.cygnus.com> <3AF02D6E.333B2AAB@redhat.com>
X-SW-Source: 2001-05/msg00010.html
Content-length: 3520

Thanks Fernando!
But shouldn't we be leaving the stuff in symbol_file_command?
I.e. only adding it to the new function?

Elena

Fernando Nasser writes:
> After the fruitful discussions with Elena, I believe I have a better
> patch, so please consider this one instead.
>
> As Elena explained, we must let the callers of symbol_file_add() do the
> cache reset as we may be loading several shared libraries. Doing the
> cache reset for each one is too much overhead as we will have to grab
> the data for filling the current frame every single time. Well,
> symbol_file_add_main () is a caller, so I guess it can go there. And
> none of its callers has a a call to reinit_frame_cache() as they used to
> call symbol_file_command().
>
> I guess the previous behavior is being safely restored now.
>
> However, several of the callers of symbol_file_add() do not call
> reinit_frame_cache() as they should. But as far as I can tell, this has
> always been like that. The only thing that is lost is the possibility
> to get a better frame description of the current stack by using the
> newly read symbols. I don't know enough about all this targets to know
> if this is important (I don't know why they are reading symbol files).
> The shared library case is already taken care of as Elena has pointed
> out.
>
>
>
> ChangeLog:
>
> * symfile.c (symbol_file_command): Move cleanup operations
> from here...
> (symbol_file_add_main): ...to here, so they are run every time
> a new main symbol file is read.
>
>
> --
> Fernando Nasser
> Red Hat Canada Ltd. E-Mail: fnasser@redhat.com
> 2323 Yonge Street, Suite #300
> Toronto, Ontario M4P 2C9Index: symfile.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symfile.c,v
> retrieving revision 1.31
> diff -c -p -r1.31 symfile.c
> *** symfile.c 2001/04/05 02:02:13 1.31
> --- symfile.c 2001/05/02 15:35:32
> *************** symbol_file_add (char *name, int from_tt
> *** 896,908 ****
> return (objfile);
> }
>
> ! /* Just call the above with default values.
> ! Used when the file is supplied in the gdb command line. */
>
> void
> symbol_file_add_main (char *args, int from_tty)
> {
> symbol_file_add (args, from_tty, NULL, 1, 0);
> }
>
> void
> --- 896,920 ----
> return (objfile);
> }
>
> ! /* Call the above with default values and update whatever is
> ! affected by a new main().
> ! Used when the file is supplied in the gdb command line
> ! and by some targets. */
>
> void
> symbol_file_add_main (char *args, int from_tty)
> {
> symbol_file_add (args, from_tty, NULL, 1, 0);
> +
> + #ifdef HPUXHPPA
> + RESET_HP_UX_GLOBALS ();
> + #endif
> +
> + /* Getting new symbols may change our opinion about
> + what is frameless. */
> + reinit_frame_cache ();
> +
> + set_initial_language ();
> }
>
> void
> *************** symbol_file_command (char *args, int fro
> *** 980,993 ****
> {
> name = *argv;
> symbol_file_add (name, from_tty, NULL, 1, flags);
> - #ifdef HPUXHPPA
> - RESET_HP_UX_GLOBALS ();
> - #endif
> - /* Getting new symbols may change our opinion about
> - what is frameless. */
> - reinit_frame_cache ();
> -
> - set_initial_language ();
> }
> argv++;
> }
> --- 992,997 ----