public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patchv4 4/5] Keep objfile original filename
@ 2013-09-19 14:20 Jan Kratochvil
  2013-09-19 23:37 ` Doug Evans
  2014-01-07 13:37 ` Yao Qi
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kratochvil @ 2013-09-19 14:20 UTC (permalink / raw)
  To: gdb-patches

Hi,

formerly:
	[patchv3 4/5] Keep objfile original filename
	https://sourceware.org/ml/gdb-patches/2013-09/msg00424.html

also in archer.git jankratochvil/dwp

It is now storing objfile->original_name in objfile_obstack.
Plus new comment in read_symbols.


Jan


gdb/
2013-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Pass down original filename for objfile.
	* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
	* elfread.c (elf_symfile_read): Likewise.
	* jit.c (jit_object_close_impl): Update allocate_objfile call, no
	longer set ORIGINAL_NAME.
	(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
	* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
	* machoread.c (macho_add_oso_symfile): Add parameter name.  Update
	symbol_file_add_from_bfd call.
	(macho_symfile_read_all_oso): Update two macho_add_oso_symfile calls.
	(macho_check_dsym): Add parameter filenamep.  Change function comment.
	Set *filenamep.
	(macho_symfile_read): New variable dsym_filename.  Update
	macho_check_dsym call.  Use it for symbol_file_add_separate.
	* objfiles.c (allocate_objfile): Add parameter name.  New comment for
	it.  Use it for objfile->original_name.
	(objfile_name): Return OBFD's filename, if available.
	* objfiles.h (allocate_objfile): Add new parameter name.
	* solib-sunos.c (allocate_rt_common_objfile): Remove variable name.
	Update allocate_objfile call.  Remove obstack_copy0 call.
	* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
	* symfile-mem.c (symbol_file_add_from_memory): Update
	symbol_file_add_from_bfd call.
	* symfile.c (read_symbols): Update symbol_file_add_separate call, new
	comment for it.
	(symbol_file_add_with_addrs): New parameter name, add function comment
	for it.  Remove variable name.  Update allocate_objfile call.
	(symbol_file_add_separate): New parameter name, add function comment
	for it.  Update symbol_file_add_with_addrs call.
	(symbol_file_add_from_bfd): New parameter name.  Update
	symbol_file_add_with_addrs call.
	(symbol_file_add): Update symbol_file_add_from_bfd call.
	(reread_symbols): New variable original_name.  Save
	objfile->original_name by it.
	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
	second parameter.

--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -738,7 +738,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags)
 	  bfd *abfd = symfile_bfd_open (debugfile);
 
 	  make_cleanup_bfd_unref (abfd);
-	  symbol_file_add_separate (abfd, symfile_flags, objfile);
+	  symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
 	}
     }
 
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1458,7 +1458,7 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
 	  bfd *abfd = symfile_bfd_open (debugfile);
 
 	  make_cleanup_bfd_unref (abfd);
-	  symbol_file_add_separate (abfd, symfile_flags, objfile);
+	  symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
 	  do_cleanups (cleanup);
 	}
     }
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -785,13 +785,11 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
 
   priv_data = cb->priv_data;
 
-  objfile = allocate_objfile (NULL, 0);
+  objfile = allocate_objfile (NULL, "<< JIT compiled code >>", 0);
   objfile->per_bfd->gdbarch = target_gdbarch ();
 
   terminate_minimal_symbol_table (objfile);
 
-  objfile->original_name = "<< JIT compiled code >>";
-
   j = NULL;
   for (i = obj->symtabs; i; i = j)
     {
@@ -927,7 +925,8 @@ JITed symbol file is not an object file, ignoring it.\n"));
 
   /* This call does not take ownership of SAI.  */
   make_cleanup_bfd_unref (nbfd);
-  objfile = symbol_file_add_from_bfd (nbfd, 0, sai, OBJF_SHARED, NULL);
+  objfile = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd), 0, sai,
+				      OBJF_SHARED, NULL);
 
   do_cleanups (old_cleanups);
   add_objfile_entry (objfile, entry_addr);
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -118,7 +118,7 @@ get_dynamics_objfile (struct gdbarch *gdbarch)
 
       /* Mark it as shared so that it is cleared when the inferior is
 	 re-run.  */
-      dynamics_objfile = allocate_objfile (NULL, OBJF_SHARED);
+      dynamics_objfile = allocate_objfile (NULL, NULL, OBJF_SHARED);
       dynamics_objfile->per_bfd->gdbarch = gdbarch;
 
       data = XCNEW (struct jv_per_objfile_data);
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -447,7 +447,7 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym)
 /* Add oso file OSO/ABFD as a symbol file.  */
 
 static void
-macho_add_oso_symfile (oso_el *oso, bfd *abfd,
+macho_add_oso_symfile (oso_el *oso, bfd *abfd, const char *name,
                        struct objfile *main_objfile, int symfile_flags)
 {
   int storage;
@@ -636,7 +636,7 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd,
      from symfile.c:symbol_file_add_with_addrs_or_offsets.  */
   cleanup = make_cleanup_bfd_unref (abfd);
   symbol_file_add_from_bfd
-    (abfd, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
+    (abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
      main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
 			    | OBJF_READNOW | OBJF_USERLOADED),
      main_objfile);
@@ -736,6 +736,7 @@ macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
                                   member_len))
                     {
                       macho_add_oso_symfile (oso2, member_bfd,
+					     bfd_get_filename (member_bfd),
                                              main_objfile, symfile_flags);
                       oso2->name = NULL;
                       break;
@@ -769,7 +770,8 @@ macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
             warning (_("`%s': can't open to read symbols: %s."), oso->name,
                      bfd_errmsg (bfd_get_error ()));
           else
-            macho_add_oso_symfile (oso, abfd, main_objfile, symfile_flags);
+            macho_add_oso_symfile (oso, abfd, oso->name, main_objfile,
+				   symfile_flags);
 
           ix++;
         }
@@ -785,11 +787,13 @@ macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
    executable name and the executable base name to get the DSYM file name.  */
 #define DSYM_SUFFIX ".dSYM/Contents/Resources/DWARF/"
 
-/* Check if a dsym file exists for OBJFILE.  If so, returns a bfd for it.
-   Return NULL if no valid dsym file is found.  */
+/* Check if a dsym file exists for OBJFILE.  If so, returns a bfd for it
+   and return *FILENAMEP with its original xmalloc-ated filename.
+   Return NULL if no valid dsym file is found (FILENAMEP is not used in
+   such case).  */
 
 static bfd *
-macho_check_dsym (struct objfile *objfile)
+macho_check_dsym (struct objfile *objfile, char **filenamep)
 {
   size_t name_len = strlen (objfile_name (objfile));
   size_t dsym_len = strlen (DSYM_SUFFIX);
@@ -842,6 +846,7 @@ macho_check_dsym (struct objfile *objfile)
       gdb_bfd_unref (dsym_bfd);
       return NULL;
     }
+  *filenamep = xstrdup (dsym_filename);
   return dsym_bfd;
 }
 
@@ -860,6 +865,8 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
      be in the executable.  */
   if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
     {
+      char *dsym_filename;
+
       /* Process the normal symbol table first.  */
       storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
       if (storage_needed < 0)
@@ -897,13 +904,15 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
       dwarf2_build_frame_info (objfile);
 
       /* Check for DSYM file.  */
-      dsym_bfd = macho_check_dsym (objfile);
+      dsym_bfd = macho_check_dsym (objfile, &dsym_filename);
       if (dsym_bfd != NULL)
 	{
 	  int ix;
 	  oso_el *oso;
           struct bfd_section *asect, *dsect;
 
+	  make_cleanup (xfree, dsym_filename);
+
 	  if (mach_o_debug_level > 0)
 	    printf_unfiltered (_("dsym file found\n"));
 
@@ -920,7 +929,8 @@ macho_symfile_read (struct objfile *objfile, int symfile_flags)
 
 	  /* Add the dsym file as a separate file.  */
 	  make_cleanup_bfd_unref (dsym_bfd);
-          symbol_file_add_separate (dsym_bfd, symfile_flags, objfile);
+          symbol_file_add_separate (dsym_bfd, dsym_filename, symfile_flags,
+				    objfile);
 
 	  /* Don't try to read dwarf2 from main file or shared libraries.  */
 	  do_cleanups (old_chain);
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -250,6 +250,11 @@ build_objfile_section_table (struct objfile *objfile)
    into the list of all known objfiles, and return a pointer to the
    new objfile struct.
 
+   NAME should contain original non-canonicalized filename or other
+   identifier as entered by user.  If there is no better source use
+   bfd_get_filename (ABFD).  NAME may be NULL only if ABFD is NULL.
+   NAME content is copied into returned objfile.
+
    The FLAGS word contains various bits (OBJF_*) that can be taken as
    requests for specific operations.  Other bits like OBJF_SHARED are
    simply copied through to the new objfile flags member.  */
@@ -264,7 +269,7 @@ build_objfile_section_table (struct objfile *objfile)
    things in a consistent state even if abfd is NULL.  */
 
 struct objfile *
-allocate_objfile (bfd *abfd, int flags)
+allocate_objfile (bfd *abfd, const char *name, int flags)
 {
   struct objfile *objfile;
 
@@ -281,20 +286,23 @@ allocate_objfile (bfd *abfd, int flags)
      that any data that is reference is saved in the per-objfile data
      region.  */
 
+  if (name == NULL)
+    {
+      gdb_assert (abfd == NULL);
+      name = "<<anonymous objfile>>";
+    }
+  objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
+					  strlen (name));
+
   objfile->obfd = abfd;
   gdb_bfd_ref (abfd);
   if (abfd != NULL)
     {
-      objfile->original_name = bfd_get_filename (abfd);
       objfile->mtime = bfd_get_mtime (abfd);
 
       /* Build section table.  */
       build_objfile_section_table (objfile);
     }
-  else
-    {
-      objfile->original_name = "<<anonymous objfile>>";
-    }
 
   objfile->per_bfd = get_objfile_bfd_data (objfile, abfd);
   objfile->pspace = current_program_space;
@@ -1491,6 +1499,9 @@ default_iterate_over_objfiles_in_search_order
 const char *
 objfile_name (const struct objfile *objfile)
 {
+  if (objfile->obfd != NULL)
+    return bfd_get_filename (objfile->obfd);
+
   return objfile->original_name;
 }
 
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -436,7 +436,7 @@ extern struct objfile *rt_common_objfile;
 
 /* Declarations for functions defined in objfiles.c */
 
-extern struct objfile *allocate_objfile (bfd *, int);
+extern struct objfile *allocate_objfile (bfd *, const char *name, int);
 
 extern struct gdbarch *get_objfile_arch (struct objfile *);
 
--- a/gdb/solib-sunos.c
+++ b/gdb/solib-sunos.c
@@ -182,11 +182,7 @@ static int match_main (char *);
 static void
 allocate_rt_common_objfile (void)
 {
-  const char name[] = "rt_common";
-
-  rt_common_objfile = allocate_objfile (NULL, 0);
-  rt_common_objfile->name = obstack_copy0 (&rt_common_objfile->objfile_obstack,
-					   name, strlen (name));
+  rt_common_objfile = allocate_objfile (NULL, "rt_common", 0);
 }
 
 /* Read all dynamically loaded common symbol definitions from the inferior
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -610,7 +610,7 @@ solib_read_symbols (struct so_list *so, int flags)
 
 	  sap = build_section_addr_info_from_section_table (so->sections,
 							    so->sections_end);
-	  so->objfile = symbol_file_add_from_bfd (so->abfd,
+	  so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name,
 						  flags, sap, OBJF_SHARED,
 						  NULL);
 	  so->objfile->addr_low = so->addr_low;
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -129,7 +129,8 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr, char *name,
       }
   sai->num_sections = i;
 
-  objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0,
+  objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
+				   from_tty ? SYMFILE_VERBOSE : 0,
                                    sai, OBJF_SHARED, NULL);
 
   /* This might change our ideas about frames already looked at.  */
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -839,7 +839,14 @@ read_symbols (struct objfile *objfile, int add_flags)
       struct cleanup *cleanup = make_cleanup_bfd_unref (abfd);
 
       if (abfd != NULL)
-	symbol_file_add_separate (abfd, add_flags, objfile);
+	{
+	  /* find_separate_debug_file_in_section uses the same filename for the
+	     virtual section-as-bfd like the bfd filename containing the
+	     section.  Therefore use also non-canonical name form for the same
+	     file containing the section.  */
+	  symbol_file_add_separate (abfd, objfile->original_name, add_flags,
+				    objfile);
+	}
 
       do_cleanups (cleanup);
     }
@@ -1047,6 +1054,8 @@ new_symfile_objfile (struct objfile *objfile, int add_flags)
    ABFD is a BFD already open on the file, as from symfile_bfd_open.
    A new reference is acquired by this function.
 
+   For NAME description see allocate_objfile's definition.
+
    ADD_FLAGS encodes verbosity, whether this is main symbol file or
    extra, such as dynamically loaded code, and what to do with breakpoins.
 
@@ -1060,12 +1069,11 @@ new_symfile_objfile (struct objfile *objfile, int add_flags)
    Upon failure, jumps back to command level (never returns).  */
 
 static struct objfile *
-symbol_file_add_with_addrs (bfd *abfd, int add_flags,
+symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags,
 			    struct section_addr_info *addrs,
 			    int flags, struct objfile *parent)
 {
   struct objfile *objfile;
-  const char *name = bfd_get_filename (abfd);
   const int from_tty = add_flags & SYMFILE_VERBOSE;
   const int mainline = add_flags & SYMFILE_MAINLINE;
   const int should_print = ((from_tty || info_verbose)
@@ -1087,7 +1095,8 @@ symbol_file_add_with_addrs (bfd *abfd, int add_flags,
       && !query (_("Load new symbol table from \"%s\"? "), name))
     error (_("Not confirmed."));
 
-  objfile = allocate_objfile (abfd, flags | (mainline ? OBJF_MAINLINE : 0));
+  objfile = allocate_objfile (abfd, name,
+			      flags | (mainline ? OBJF_MAINLINE : 0));
 
   if (parent)
     add_separate_debug_objfile (objfile, parent);
@@ -1160,10 +1169,12 @@ symbol_file_add_with_addrs (bfd *abfd, int add_flags,
   return (objfile);
 }
 
-/* Add BFD as a separate debug file for OBJFILE.  */
+/* Add BFD as a separate debug file for OBJFILE.  For NAME description
+   see allocate_objfile's definition.  */
 
 void
-symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
+symbol_file_add_separate (bfd *bfd, const char *name, int symfile_flags,
+			  struct objfile *objfile)
 {
   struct objfile *new_objfile;
   struct section_addr_info *sap;
@@ -1176,7 +1187,7 @@ symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
   my_cleanup = make_cleanup_free_section_addr_info (sap);
 
   new_objfile = symbol_file_add_with_addrs
-    (bfd, symfile_flags, sap,
+    (bfd, name, symfile_flags, sap,
      objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
 		       | OBJF_USERLOADED),
      objfile);
@@ -1189,11 +1200,12 @@ symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
    See symbol_file_add_with_addrs's comments for details.  */
 
 struct objfile *
-symbol_file_add_from_bfd (bfd *abfd, int add_flags,
+symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
                           struct section_addr_info *addrs,
                           int flags, struct objfile *parent)
 {
-  return symbol_file_add_with_addrs (abfd, add_flags, addrs, flags, parent);
+  return symbol_file_add_with_addrs (abfd, name, add_flags, addrs, flags,
+				     parent);
 }
 
 /* Process a symbol file, as either the main file or as a dynamically
@@ -1207,7 +1219,7 @@ symbol_file_add (const char *name, int add_flags,
   struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
   struct objfile *objf;
 
-  objf = symbol_file_add_from_bfd (bfd, add_flags, addrs, flags, NULL);
+  objf = symbol_file_add_from_bfd (bfd, name, add_flags, addrs, flags, NULL);
   do_cleanups (cleanup);
   return objf;
 }
@@ -2373,6 +2385,7 @@ reread_symbols (void)
 	  struct cleanup *old_cleanups;
 	  struct section_offsets *offsets;
 	  int num_offsets;
+	  char *original_name;
 
 	  printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"),
 			     objfile_name (objfile));
@@ -2443,7 +2456,9 @@ reread_symbols (void)
 	    gdb_bfd_unref (obfd);
 	  }
 
-	  objfile->original_name = bfd_get_filename (objfile->obfd);
+	  original_name = xstrdup (objfile->original_name);
+	  make_cleanup (xfree, original_name);
+
 	  /* bfd_openr sets cacheable to true, which is what we want.  */
 	  if (!bfd_check_format (objfile->obfd, bfd_object))
 	    error (_("Can't read symbols from %s: %s."), objfile_name (objfile),
@@ -2497,6 +2512,10 @@ reread_symbols (void)
 	     gdb_obstack.h specifies the alloc/dealloc functions.  */
 	  obstack_init (&objfile->objfile_obstack);
 
+	  objfile->original_name = obstack_copy0 (&objfile->objfile_obstack,
+						  original_name,
+						  strlen (original_name));
+
 	  /* Reset the sym_fns pointer.  The ELF reader can change it
 	     based on whether .gdb_index is present, and we need it to
 	     start over.  PR symtab/15885  */
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -480,11 +480,12 @@ extern void new_symfile_objfile (struct objfile *, int);
 extern struct objfile *symbol_file_add (const char *, int,
 					struct section_addr_info *, int);
 
-extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
+extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, int,
                                                  struct section_addr_info *,
                                                  int, struct objfile *parent);
 
-extern void symbol_file_add_separate (bfd *, int, struct objfile *);
+extern void symbol_file_add_separate (bfd *, const char *, int,
+				      struct objfile *);
 
 extern char *find_separate_debug_file_by_debuglink (struct objfile *);
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2013-09-19 14:20 [patchv4 4/5] Keep objfile original filename Jan Kratochvil
@ 2013-09-19 23:37 ` Doug Evans
  2013-09-24 14:01   ` [commit] " Jan Kratochvil
  2014-01-07 13:37 ` Yao Qi
  1 sibling, 1 reply; 8+ messages in thread
From: Doug Evans @ 2013-09-19 23:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Jan Kratochvil writes:
 > gdb/
 > 2013-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 > 
 > 	Pass down original filename for objfile.
 > 	* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
 > 	* elfread.c (elf_symfile_read): Likewise.
 > 	* jit.c (jit_object_close_impl): Update allocate_objfile call, no
 > 	longer set ORIGINAL_NAME.
 > 	(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
 > 	* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
 > 	* machoread.c (macho_add_oso_symfile): Add parameter name.  Update
 > 	symbol_file_add_from_bfd call.
 > 	(macho_symfile_read_all_oso): Update two macho_add_oso_symfile calls.
 > 	(macho_check_dsym): Add parameter filenamep.  Change function comment.
 > 	Set *filenamep.
 > 	(macho_symfile_read): New variable dsym_filename.  Update
 > 	macho_check_dsym call.  Use it for symbol_file_add_separate.
 > 	* objfiles.c (allocate_objfile): Add parameter name.  New comment for
 > 	it.  Use it for objfile->original_name.
 > 	(objfile_name): Return OBFD's filename, if available.
 > 	* objfiles.h (allocate_objfile): Add new parameter name.
 > 	* solib-sunos.c (allocate_rt_common_objfile): Remove variable name.
 > 	Update allocate_objfile call.  Remove obstack_copy0 call.
 > 	* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
 > 	* symfile-mem.c (symbol_file_add_from_memory): Update
 > 	symbol_file_add_from_bfd call.
 > 	* symfile.c (read_symbols): Update symbol_file_add_separate call, new
 > 	comment for it.
 > 	(symbol_file_add_with_addrs): New parameter name, add function comment
 > 	for it.  Remove variable name.  Update allocate_objfile call.
 > 	(symbol_file_add_separate): New parameter name, add function comment
 > 	for it.  Update symbol_file_add_with_addrs call.
 > 	(symbol_file_add_from_bfd): New parameter name.  Update
 > 	symbol_file_add_with_addrs call.
 > 	(symbol_file_add): Update symbol_file_add_from_bfd call.
 > 	(reread_symbols): New variable original_name.  Save
 > 	objfile->original_name by it.
 > 	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
 > 	second parameter.

LGTM

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [commit] [patchv4 4/5] Keep objfile original filename
  2013-09-19 23:37 ` Doug Evans
@ 2013-09-24 14:01   ` Jan Kratochvil
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Kratochvil @ 2013-09-24 14:01 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

On Fri, 20 Sep 2013 01:37:10 +0200, Doug Evans wrote:
> LGTM

Checked in; just without this change (file is deleted now):

	* solib-sunos.c (allocate_rt_common_objfile): Remove variable name.
	Update allocate_objfile call.  Remove obstack_copy0 call.


Thanks,
Jan


https://sourceware.org/ml/gdb-cvs/2013-09/msg00140.html

--- src/gdb/ChangeLog	2013/09/24 13:57:36	1.16023
+++ src/gdb/ChangeLog	2013/09/24 14:00:05	1.16024
@@ -1,5 +1,42 @@
 2013-09-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Pass down original filename for objfile.
+	* coffread.c (coff_symfile_read): Update symbol_file_add_separate call.
+	* elfread.c (elf_symfile_read): Likewise.
+	* jit.c (jit_object_close_impl): Update allocate_objfile call, no
+	longer set ORIGINAL_NAME.
+	(jit_bfd_try_read_symtab): Update symbol_file_add_from_bfd call.
+	* jv-lang.c (get_dynamics_objfile): Update allocate_objfile call.
+	* machoread.c (macho_add_oso_symfile): Add parameter name.  Update
+	symbol_file_add_from_bfd call.
+	(macho_symfile_read_all_oso): Update two macho_add_oso_symfile calls.
+	(macho_check_dsym): Add parameter filenamep.  Change function comment.
+	Set *filenamep.
+	(macho_symfile_read): New variable dsym_filename.  Update
+	macho_check_dsym call.  Use it for symbol_file_add_separate.
+	* objfiles.c (allocate_objfile): Add parameter name.  New comment for
+	it.  Use it for objfile->original_name.
+	(objfile_name): Return OBFD's filename, if available.
+	* objfiles.h (allocate_objfile): Add new parameter name.
+	* solib.c (solib_read_symbols): Update symbol_file_add_from_bfd call.
+	* symfile-mem.c (symbol_file_add_from_memory): Update
+	symbol_file_add_from_bfd call.
+	* symfile.c (read_symbols): Update symbol_file_add_separate call, new
+	comment for it.
+	(symbol_file_add_with_addrs): New parameter name, add function comment
+	for it.  Remove variable name.  Update allocate_objfile call.
+	(symbol_file_add_separate): New parameter name, add function comment
+	for it.  Update symbol_file_add_with_addrs call.
+	(symbol_file_add_from_bfd): New parameter name.  Update
+	symbol_file_add_with_addrs call.
+	(symbol_file_add): Update symbol_file_add_from_bfd call.
+	(reread_symbols): New variable original_name.  Save
+	objfile->original_name by it.
+	* symfile.h (symbol_file_add_from_bfd, symbol_file_add_separate): Add
+	second parameter.
+
+2013-09-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	Code cleanup: Add objfile_name accessor function.
 	* ada-lang.c (is_known_support_routine): Use objfile_name.
 	* auto-load.c (source_gdb_script_for_objfile)
--- src/gdb/coffread.c	2013/09/24 13:57:36	1.148
+++ src/gdb/coffread.c	2013/09/24 14:00:06	1.149
@@ -738,7 +738,7 @@
 	  bfd *abfd = symfile_bfd_open (debugfile);
 
 	  make_cleanup_bfd_unref (abfd);
-	  symbol_file_add_separate (abfd, symfile_flags, objfile);
+	  symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
 	}
     }
 
--- src/gdb/elfread.c	2013/09/24 13:57:37	1.159
+++ src/gdb/elfread.c	2013/09/24 14:00:06	1.160
@@ -1458,7 +1458,7 @@
 	  bfd *abfd = symfile_bfd_open (debugfile);
 
 	  make_cleanup_bfd_unref (abfd);
-	  symbol_file_add_separate (abfd, symfile_flags, objfile);
+	  symbol_file_add_separate (abfd, debugfile, symfile_flags, objfile);
 	  do_cleanups (cleanup);
 	}
     }
--- src/gdb/jit.c	2013/09/24 13:57:37	1.55
+++ src/gdb/jit.c	2013/09/24 14:00:06	1.56
@@ -785,13 +785,11 @@
 
   priv_data = cb->priv_data;
 
-  objfile = allocate_objfile (NULL, 0);
+  objfile = allocate_objfile (NULL, "<< JIT compiled code >>", 0);
   objfile->per_bfd->gdbarch = target_gdbarch ();
 
   terminate_minimal_symbol_table (objfile);
 
-  objfile->original_name = "<< JIT compiled code >>";
-
   j = NULL;
   for (i = obj->symtabs; i; i = j)
     {
@@ -927,7 +925,8 @@
 
   /* This call does not take ownership of SAI.  */
   make_cleanup_bfd_unref (nbfd);
-  objfile = symbol_file_add_from_bfd (nbfd, 0, sai, OBJF_SHARED, NULL);
+  objfile = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd), 0, sai,
+				      OBJF_SHARED, NULL);
 
   do_cleanups (old_cleanups);
   add_objfile_entry (objfile, entry_addr);
--- src/gdb/jv-lang.c	2013/08/20 15:04:51	1.111
+++ src/gdb/jv-lang.c	2013/09/24 14:00:06	1.112
@@ -118,7 +118,7 @@
 
       /* Mark it as shared so that it is cleared when the inferior is
 	 re-run.  */
-      dynamics_objfile = allocate_objfile (NULL, OBJF_SHARED);
+      dynamics_objfile = allocate_objfile (NULL, NULL, OBJF_SHARED);
       dynamics_objfile->per_bfd->gdbarch = gdbarch;
 
       data = XCNEW (struct jv_per_objfile_data);
--- src/gdb/machoread.c	2013/09/24 13:57:37	1.57
+++ src/gdb/machoread.c	2013/09/24 14:00:06	1.58
@@ -447,7 +447,7 @@
 /* Add oso file OSO/ABFD as a symbol file.  */
 
 static void
-macho_add_oso_symfile (oso_el *oso, bfd *abfd,
+macho_add_oso_symfile (oso_el *oso, bfd *abfd, const char *name,
                        struct objfile *main_objfile, int symfile_flags)
 {
   int storage;
@@ -636,7 +636,7 @@
      from symfile.c:symbol_file_add_with_addrs_or_offsets.  */
   cleanup = make_cleanup_bfd_unref (abfd);
   symbol_file_add_from_bfd
-    (abfd, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
+    (abfd, name, symfile_flags & ~(SYMFILE_MAINLINE | SYMFILE_VERBOSE), NULL,
      main_objfile->flags & (OBJF_REORDERED | OBJF_SHARED
 			    | OBJF_READNOW | OBJF_USERLOADED),
      main_objfile);
@@ -736,6 +736,7 @@
                                   member_len))
                     {
                       macho_add_oso_symfile (oso2, member_bfd,
+					     bfd_get_filename (member_bfd),
                                              main_objfile, symfile_flags);
                       oso2->name = NULL;
                       break;
@@ -769,7 +770,8 @@
             warning (_("`%s': can't open to read symbols: %s."), oso->name,
                      bfd_errmsg (bfd_get_error ()));
           else
-            macho_add_oso_symfile (oso, abfd, main_objfile, symfile_flags);
+            macho_add_oso_symfile (oso, abfd, oso->name, main_objfile,
+				   symfile_flags);
 
           ix++;
         }
@@ -785,11 +787,13 @@
    executable name and the executable base name to get the DSYM file name.  */
 #define DSYM_SUFFIX ".dSYM/Contents/Resources/DWARF/"
 
-/* Check if a dsym file exists for OBJFILE.  If so, returns a bfd for it.
-   Return NULL if no valid dsym file is found.  */
+/* Check if a dsym file exists for OBJFILE.  If so, returns a bfd for it
+   and return *FILENAMEP with its original xmalloc-ated filename.
+   Return NULL if no valid dsym file is found (FILENAMEP is not used in
+   such case).  */
 
 static bfd *
-macho_check_dsym (struct objfile *objfile)
+macho_check_dsym (struct objfile *objfile, char **filenamep)
 {
   size_t name_len = strlen (objfile_name (objfile));
   size_t dsym_len = strlen (DSYM_SUFFIX);
@@ -842,6 +846,7 @@
       gdb_bfd_unref (dsym_bfd);
       return NULL;
     }
+  *filenamep = xstrdup (dsym_filename);
   return dsym_bfd;
 }
 
@@ -860,6 +865,8 @@
      be in the executable.  */
   if (bfd_get_file_flags (abfd) & (EXEC_P | DYNAMIC))
     {
+      char *dsym_filename;
+
       /* Process the normal symbol table first.  */
       storage_needed = bfd_get_symtab_upper_bound (objfile->obfd);
       if (storage_needed < 0)
@@ -897,13 +904,15 @@
       dwarf2_build_frame_info (objfile);
 
       /* Check for DSYM file.  */
-      dsym_bfd = macho_check_dsym (objfile);
+      dsym_bfd = macho_check_dsym (objfile, &dsym_filename);
       if (dsym_bfd != NULL)
 	{
 	  int ix;
 	  oso_el *oso;
           struct bfd_section *asect, *dsect;
 
+	  make_cleanup (xfree, dsym_filename);
+
 	  if (mach_o_debug_level > 0)
 	    printf_unfiltered (_("dsym file found\n"));
 
@@ -920,7 +929,8 @@
 
 	  /* Add the dsym file as a separate file.  */
 	  make_cleanup_bfd_unref (dsym_bfd);
-          symbol_file_add_separate (dsym_bfd, symfile_flags, objfile);
+          symbol_file_add_separate (dsym_bfd, dsym_filename, symfile_flags,
+				    objfile);
 
 	  /* Don't try to read dwarf2 from main file or shared libraries.  */
 	  do_cleanups (old_chain);
--- src/gdb/objfiles.c	2013/09/24 13:57:37	1.165
+++ src/gdb/objfiles.c	2013/09/24 14:00:06	1.166
@@ -248,6 +248,11 @@
    into the list of all known objfiles, and return a pointer to the
    new objfile struct.
 
+   NAME should contain original non-canonicalized filename or other
+   identifier as entered by user.  If there is no better source use
+   bfd_get_filename (ABFD).  NAME may be NULL only if ABFD is NULL.
+   NAME content is copied into returned objfile.
+
    The FLAGS word contains various bits (OBJF_*) that can be taken as
    requests for specific operations.  Other bits like OBJF_SHARED are
    simply copied through to the new objfile flags member.  */
@@ -262,7 +267,7 @@
    things in a consistent state even if abfd is NULL.  */
 
 struct objfile *
-allocate_objfile (bfd *abfd, int flags)
+allocate_objfile (bfd *abfd, const char *name, int flags)
 {
   struct objfile *objfile;
 
@@ -279,20 +284,23 @@
      that any data that is reference is saved in the per-objfile data
      region.  */
 
+  if (name == NULL)
+    {
+      gdb_assert (abfd == NULL);
+      name = "<<anonymous objfile>>";
+    }
+  objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
+					  strlen (name));
+
   objfile->obfd = abfd;
   gdb_bfd_ref (abfd);
   if (abfd != NULL)
     {
-      objfile->original_name = bfd_get_filename (abfd);
       objfile->mtime = bfd_get_mtime (abfd);
 
       /* Build section table.  */
       build_objfile_section_table (objfile);
     }
-  else
-    {
-      objfile->original_name = "<<anonymous objfile>>";
-    }
 
   objfile->per_bfd = get_objfile_bfd_data (objfile, abfd);
   objfile->pspace = current_program_space;
@@ -1486,6 +1494,9 @@
 const char *
 objfile_name (const struct objfile *objfile)
 {
+  if (objfile->obfd != NULL)
+    return bfd_get_filename (objfile->obfd);
+
   return objfile->original_name;
 }
 
--- src/gdb/objfiles.h	2013/09/24 13:57:37	1.111
+++ src/gdb/objfiles.h	2013/09/24 14:00:06	1.112
@@ -431,7 +431,7 @@
 
 /* Declarations for functions defined in objfiles.c */
 
-extern struct objfile *allocate_objfile (bfd *, int);
+extern struct objfile *allocate_objfile (bfd *, const char *name, int);
 
 extern struct gdbarch *get_objfile_arch (struct objfile *);
 
--- src/gdb/solib.c	2013/09/24 13:57:37	1.179
+++ src/gdb/solib.c	2013/09/24 14:00:06	1.180
@@ -610,7 +610,7 @@
 
 	  sap = build_section_addr_info_from_section_table (so->sections,
 							    so->sections_end);
-	  so->objfile = symbol_file_add_from_bfd (so->abfd,
+	  so->objfile = symbol_file_add_from_bfd (so->abfd, so->so_name,
 						  flags, sap, OBJF_SHARED,
 						  NULL);
 	  so->objfile->addr_low = so->addr_low;
--- src/gdb/symfile-mem.c	2013/03/21 16:18:48	1.35
+++ src/gdb/symfile-mem.c	2013/09/24 14:00:06	1.36
@@ -129,7 +129,8 @@
       }
   sai->num_sections = i;
 
-  objf = symbol_file_add_from_bfd (nbfd, from_tty ? SYMFILE_VERBOSE : 0,
+  objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
+				   from_tty ? SYMFILE_VERBOSE : 0,
                                    sai, OBJF_SHARED, NULL);
 
   /* This might change our ideas about frames already looked at.  */
--- src/gdb/symfile.c	2013/09/24 13:57:37	1.392
+++ src/gdb/symfile.c	2013/09/24 14:00:06	1.393
@@ -839,7 +839,14 @@
       struct cleanup *cleanup = make_cleanup_bfd_unref (abfd);
 
       if (abfd != NULL)
-	symbol_file_add_separate (abfd, add_flags, objfile);
+	{
+	  /* find_separate_debug_file_in_section uses the same filename for the
+	     virtual section-as-bfd like the bfd filename containing the
+	     section.  Therefore use also non-canonical name form for the same
+	     file containing the section.  */
+	  symbol_file_add_separate (abfd, objfile->original_name, add_flags,
+				    objfile);
+	}
 
       do_cleanups (cleanup);
     }
@@ -1047,6 +1054,8 @@
    ABFD is a BFD already open on the file, as from symfile_bfd_open.
    A new reference is acquired by this function.
 
+   For NAME description see allocate_objfile's definition.
+
    ADD_FLAGS encodes verbosity, whether this is main symbol file or
    extra, such as dynamically loaded code, and what to do with breakpoins.
 
@@ -1060,12 +1069,11 @@
    Upon failure, jumps back to command level (never returns).  */
 
 static struct objfile *
-symbol_file_add_with_addrs (bfd *abfd, int add_flags,
+symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags,
 			    struct section_addr_info *addrs,
 			    int flags, struct objfile *parent)
 {
   struct objfile *objfile;
-  const char *name = bfd_get_filename (abfd);
   const int from_tty = add_flags & SYMFILE_VERBOSE;
   const int mainline = add_flags & SYMFILE_MAINLINE;
   const int should_print = ((from_tty || info_verbose)
@@ -1087,7 +1095,8 @@
       && !query (_("Load new symbol table from \"%s\"? "), name))
     error (_("Not confirmed."));
 
-  objfile = allocate_objfile (abfd, flags | (mainline ? OBJF_MAINLINE : 0));
+  objfile = allocate_objfile (abfd, name,
+			      flags | (mainline ? OBJF_MAINLINE : 0));
 
   if (parent)
     add_separate_debug_objfile (objfile, parent);
@@ -1160,10 +1169,12 @@
   return (objfile);
 }
 
-/* Add BFD as a separate debug file for OBJFILE.  */
+/* Add BFD as a separate debug file for OBJFILE.  For NAME description
+   see allocate_objfile's definition.  */
 
 void
-symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
+symbol_file_add_separate (bfd *bfd, const char *name, int symfile_flags,
+			  struct objfile *objfile)
 {
   struct objfile *new_objfile;
   struct section_addr_info *sap;
@@ -1176,7 +1187,7 @@
   my_cleanup = make_cleanup_free_section_addr_info (sap);
 
   new_objfile = symbol_file_add_with_addrs
-    (bfd, symfile_flags, sap,
+    (bfd, name, symfile_flags, sap,
      objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
 		       | OBJF_USERLOADED),
      objfile);
@@ -1189,11 +1200,12 @@
    See symbol_file_add_with_addrs's comments for details.  */
 
 struct objfile *
-symbol_file_add_from_bfd (bfd *abfd, int add_flags,
+symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
                           struct section_addr_info *addrs,
                           int flags, struct objfile *parent)
 {
-  return symbol_file_add_with_addrs (abfd, add_flags, addrs, flags, parent);
+  return symbol_file_add_with_addrs (abfd, name, add_flags, addrs, flags,
+				     parent);
 }
 
 /* Process a symbol file, as either the main file or as a dynamically
@@ -1207,7 +1219,7 @@
   struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
   struct objfile *objf;
 
-  objf = symbol_file_add_from_bfd (bfd, add_flags, addrs, flags, NULL);
+  objf = symbol_file_add_from_bfd (bfd, name, add_flags, addrs, flags, NULL);
   do_cleanups (cleanup);
   return objf;
 }
@@ -2372,6 +2384,7 @@
 	  struct cleanup *old_cleanups;
 	  struct section_offsets *offsets;
 	  int num_offsets;
+	  char *original_name;
 
 	  printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"),
 			     objfile_name (objfile));
@@ -2442,7 +2455,9 @@
 	    gdb_bfd_unref (obfd);
 	  }
 
-	  objfile->original_name = bfd_get_filename (objfile->obfd);
+	  original_name = xstrdup (objfile->original_name);
+	  make_cleanup (xfree, original_name);
+
 	  /* bfd_openr sets cacheable to true, which is what we want.  */
 	  if (!bfd_check_format (objfile->obfd, bfd_object))
 	    error (_("Can't read symbols from %s: %s."), objfile_name (objfile),
@@ -2496,6 +2511,10 @@
 	     gdb_obstack.h specifies the alloc/dealloc functions.  */
 	  obstack_init (&objfile->objfile_obstack);
 
+	  objfile->original_name = obstack_copy0 (&objfile->objfile_obstack,
+						  original_name,
+						  strlen (original_name));
+
 	  /* Reset the sym_fns pointer.  The ELF reader can change it
 	     based on whether .gdb_index is present, and we need it to
 	     start over.  PR symtab/15885  */
--- src/gdb/symfile.h	2013/09/19 12:44:46	1.130
+++ src/gdb/symfile.h	2013/09/24 14:00:06	1.131
@@ -480,11 +480,12 @@
 extern struct objfile *symbol_file_add (const char *, int,
 					struct section_addr_info *, int);
 
-extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
+extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, int,
                                                  struct section_addr_info *,
                                                  int, struct objfile *parent);
 
-extern void symbol_file_add_separate (bfd *, int, struct objfile *);
+extern void symbol_file_add_separate (bfd *, const char *, int,
+				      struct objfile *);
 
 extern char *find_separate_debug_file_by_debuglink (struct objfile *);
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2013-09-19 14:20 [patchv4 4/5] Keep objfile original filename Jan Kratochvil
  2013-09-19 23:37 ` Doug Evans
@ 2014-01-07 13:37 ` Yao Qi
  2014-01-07 18:47   ` Jan Kratochvil
  1 sibling, 1 reply; 8+ messages in thread
From: Yao Qi @ 2014-01-07 13:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 09/19/2013 09:56 PM, Jan Kratochvil wrote:
> @@ -1189,11 +1200,12 @@ symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
>     See symbol_file_add_with_addrs's comments for details.  */
>  
>  struct objfile *
> -symbol_file_add_from_bfd (bfd *abfd, int add_flags,
> +symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
>                            struct section_addr_info *addrs,
>                            int flags, struct objfile *parent)

We add an argument name here, but don't update
spu_symbol_file_add_from_memory in spu-linux-nat.c.  We get a build
error below, when we build GDB with --target=spu-elf on powerpc-linux
machine.

../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 2 of ‘symbol_file_add_from_bfd’ makes pointer from integer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘const char *’ but argument is of type ‘int’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 3 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: passing argument 5 of ‘symbol_file_add_from_bfd’ makes integer from pointer without a cast [-Werror]
In file included from ../../binutils-gdb/gdb/spu-linux-nat.c:29:0:
../../binutils-gdb/gdb/symfile.h:444:24: note: expected ‘int’ but argument is of type ‘void *’
../../binutils-gdb/gdb/spu-linux-nat.c:383:5: error: too few arguments to function ‘symbol_file_add_from_bfd’

This patch fixes the build error, but I am not sure NAME we passed to
symbol_file_add_from_bfd is desired. IIUC, the NAME is "<in-memory>".
I didn't run testsuite.  Is it OK?

-- 
Yao (齐尧)

gdb:

2014-01-07  Yao Qi  <yao@codesourcery.com>

	* spu-linux-nat.c (spu_symbol_file_add_from_memory): Pass
	return value of bfd_get_filename to symbol_file_add_from_bfd.
---
 gdb/spu-linux-nat.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index 9441e02..cfd5fd9 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -379,7 +379,8 @@ spu_symbol_file_add_from_memory (int inferior_fd)
     {
       struct cleanup *cleanup = make_cleanup_bfd_unref (nbfd);
 
-      symbol_file_add_from_bfd (nbfd, SYMFILE_VERBOSE | SYMFILE_MAINLINE,
+      symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
+				SYMFILE_VERBOSE | SYMFILE_MAINLINE,
 				NULL, 0, NULL);
       do_cleanups (cleanup);
     }
-- 
1.7.7.6

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2014-01-07 13:37 ` Yao Qi
@ 2014-01-07 18:47   ` Jan Kratochvil
  2014-01-08  2:47     ` Yao Qi
  2014-01-08  3:23     ` Tom Tromey
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Kratochvil @ 2014-01-07 18:47 UTC (permalink / raw)
  To: Yao Qi; +Cc: gdb-patches

On Tue, 07 Jan 2014 14:35:45 +0100, Yao Qi wrote:
> We add an argument name here, but don't update
> spu_symbol_file_add_from_memory in spu-linux-nat.c.  We get a build
> error below, when we build GDB with --target=spu-elf on powerpc-linux
> machine.

Sorry I did not build GDB on all archs; despite I have ppc accessible.


> This patch fixes the build error, but I am not sure NAME we passed to
> symbol_file_add_from_bfd is desired. IIUC, the NAME is "<in-memory>".
> I didn't run testsuite.  Is it OK?

Yes, it is OK.  The parameter is there for a difference for real disk files
between their original name with symlinks vs. their realpath() name.


Thanks,
Jan


> --- a/gdb/spu-linux-nat.c
> +++ b/gdb/spu-linux-nat.c
> @@ -379,7 +379,8 @@ spu_symbol_file_add_from_memory (int inferior_fd)
>      {
>        struct cleanup *cleanup = make_cleanup_bfd_unref (nbfd);
>  
> -      symbol_file_add_from_bfd (nbfd, SYMFILE_VERBOSE | SYMFILE_MAINLINE,
> +      symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
> +				SYMFILE_VERBOSE | SYMFILE_MAINLINE,
>  				NULL, 0, NULL);
>        do_cleanups (cleanup);
>      }
> -- 
> 1.7.7.6

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2014-01-07 18:47   ` Jan Kratochvil
@ 2014-01-08  2:47     ` Yao Qi
  2014-01-08  3:23     ` Tom Tromey
  1 sibling, 0 replies; 8+ messages in thread
From: Yao Qi @ 2014-01-08  2:47 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

On 01/08/2014 02:47 AM, Jan Kratochvil wrote:
> Yes, it is OK.  The parameter is there for a difference for real disk files
> between their original name with symlinks vs. their realpath() name.

Thanks for the quick review.  Patch is pushed.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2014-01-07 18:47   ` Jan Kratochvil
  2014-01-08  2:47     ` Yao Qi
@ 2014-01-08  3:23     ` Tom Tromey
  2014-01-08  6:26       ` Yao Qi
  1 sibling, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2014-01-08  3:23 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Yao Qi, gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

>> We add an argument name here, but don't update
>> spu_symbol_file_add_from_memory in spu-linux-nat.c.  We get a build
>> error below, when we build GDB with --target=spu-elf on powerpc-linux
>> machine.

Jan> Sorry I did not build GDB on all archs; despite I have ppc accessible.

Should this be the default for a native PPC build?

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patchv4 4/5] Keep objfile original filename
  2014-01-08  3:23     ` Tom Tromey
@ 2014-01-08  6:26       ` Yao Qi
  0 siblings, 0 replies; 8+ messages in thread
From: Yao Qi @ 2014-01-08  6:26 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Jan Kratochvil, gdb-patches

On 01/08/2014 11:23 AM, Tom Tromey wrote:
> Jan> Sorry I did not build GDB on all archs; despite I have ppc accessible.
> 
> Should this be the default for a native PPC build?

No, spu-linux-nat.c is built when --target=spu-elf --host=powerpc-linux.

-- 
Yao (齐尧)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-01-08  6:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-19 14:20 [patchv4 4/5] Keep objfile original filename Jan Kratochvil
2013-09-19 23:37 ` Doug Evans
2013-09-24 14:01   ` [commit] " Jan Kratochvil
2014-01-07 13:37 ` Yao Qi
2014-01-07 18:47   ` Jan Kratochvil
2014-01-08  2:47     ` Yao Qi
2014-01-08  3:23     ` Tom Tromey
2014-01-08  6:26       ` Yao Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).