This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patchv4 3/5] new: solib-sunos.c objfile unification [test needed]
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 19 Sep 2013 15:56:23 +0200
- Subject: [patchv4 3/5] new: solib-sunos.c objfile unification [test needed]
- Authentication-results: sourceware.org; auth=none
Hi,
I would appreciate testing this (probably a full testsuite diff needed) on
Solaris. I found some local older Opensolaris VM here but recent GDB fails to
build there (on gnulib fnmatch*); according to Joel recent GDBs build fine on
real Solaris.
The reason is apparently that objfile should be created at a single place,
otherwise various changes need to be done at multiple places etc.
But unfortunately I do not see the reason why the code did not use
allocate_objfile() already. It was added this way by this release from
https://github.com/palves/gdb-old-releases.git but I do not know why:
commit e62555e9d0cf7be157ac62cc31a3d1d079ba271b
Date: Wed Feb 1 19:21:24 1995 +0100
gdb-4.14+gdb-4.14-testsuite
also in archer.git jankratochvil/dwp
Thanks,
Jan
gdb/
2013-09-18 Jan Kratochvil <jan.kratochvil@redhat.com>
* solib-sunos.c (allocate_rt_common_objfile): Replace it by an
allocate_objfile call.
(solib_add_common_symbols): Call free_objfile and allocate_objfile
instead.
--- a/gdb/solib-sunos.c
+++ b/gdb/solib-sunos.c
@@ -182,31 +182,11 @@ static int match_main (char *);
static void
allocate_rt_common_objfile (void)
{
- struct objfile *objfile;
- struct objfile *last_one;
-
- objfile = (struct objfile *) xmalloc (sizeof (struct objfile));
- memset (objfile, 0, sizeof (struct objfile));
- objfile->psymbol_cache = psymbol_bcache_init ();
- objfile->macro_cache = bcache_xmalloc (NULL, NULL);
- objfile->filename_cache = bcache_xmalloc (NULL, NULL);
- obstack_init (&objfile->objfile_obstack);
- objfile->name = xstrdup ("rt_common");
-
- /* Add this file onto the tail of the linked list of other such files. */
-
- objfile->next = NULL;
- if (object_files == NULL)
- object_files = objfile;
- else
- {
- for (last_one = object_files;
- last_one->next;
- last_one = last_one->next);
- last_one->next = objfile;
- }
+ const char name[] = "rt_common";
- rt_common_objfile = objfile;
+ rt_common_objfile = allocate_objfile (NULL, 0);
+ rt_common_objfile->name = obstack_copy0 (&rt_common_objfile->objfile_obstack,
+ name, strlen (name));
}
/* Read all dynamically loaded common symbol definitions from the inferior
@@ -225,10 +205,8 @@ solib_add_common_symbols (CORE_ADDR rtc_symp)
if (rt_common_objfile != NULL && rt_common_objfile->minimal_symbol_count)
{
- obstack_free (&rt_common_objfile->objfile_obstack, 0);
- obstack_init (&rt_common_objfile->objfile_obstack);
- rt_common_objfile->minimal_symbol_count = 0;
- rt_common_objfile->msymbols = NULL;
+ free_objfile (rt_common_objfile);
+ allocate_rt_common_objfile ();
terminate_minimal_symbol_table (rt_common_objfile);
}