This is the mail archive of the gdb-patches@sourceware.org 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]
Other format: [Raw text]

[commit] Evaluate SPU name note


Hello,

this patch changes spu-linux-nat to evaluate the SPU name note of
in-memory SPU ELF executable BFDs and use it to set the BFD filename.
This allows setting the "from_tty" argument in the symbol_file_add_from_bfd,
so that we get the same "Reading symbols from ..." message that we see
with other native targets.

Tested on spu-elf, fixes two FAILs in the attach.exp test case.
Committed to mainline.

Bye,
Ulrich

ChangeLog:

	* spu-linux-nat.c (spu_bfd_open): Set filename of in-memory
	BFD to contents of SPU name note.
	(spu_symbol_file_add_from_memory): Call symbol_file_add_from_bfd
	with "from_tty" argument 1 instead of 0.


Index: gdb/spu-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/spu-linux-nat.c,v
retrieving revision 1.19
diff -c -p -r1.19 spu-linux-nat.c
*** gdb/spu-linux-nat.c	23 Feb 2009 00:03:50 -0000	1.19
--- gdb/spu-linux-nat.c	3 Apr 2009 14:21:20 -0000
*************** static bfd *
*** 308,313 ****
--- 308,314 ----
  spu_bfd_open (ULONGEST addr)
  {
    struct bfd *nbfd;
+   asection *spu_name;
  
    ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
    *open_closure = addr;
*************** spu_bfd_open (ULONGEST addr)
*** 325,330 ****
--- 326,347 ----
        return NULL;
      }
  
+   /* Retrieve SPU name note and update BFD name.  */
+   spu_name = bfd_get_section_by_name (nbfd, ".note.spu_name");
+   if (spu_name)
+     {
+       int sect_size = bfd_section_size (nbfd, spu_name);
+       if (sect_size > 20)
+ 	{
+ 	  char *buf = alloca (sect_size - 20 + 1);
+ 	  bfd_get_section_contents (nbfd, spu_name, buf, 20, sect_size - 20);
+ 	  buf[sect_size - 20] = '\0';
+ 
+ 	  xfree ((char *)nbfd->filename);+ 	  nbfd->filename = xstrdup (buf);
+ 	}
+     }
+ 
    return nbfd;
  }
  
*************** spu_symbol_file_add_from_memory (int inf
*** 355,361 ****
    /* Open BFD representing SPE executable and read its symbols.  */
    nbfd = spu_bfd_open (addr);
    if (nbfd)
!     symbol_file_add_from_bfd (nbfd, 0, NULL, 1, 0);
  }
  
  
--- 372,378 ----
    /* Open BFD representing SPE executable and read its symbols.  */
    nbfd = spu_bfd_open (addr);
    if (nbfd)
!     symbol_file_add_from_bfd (nbfd, 1, NULL, 1, 0);
  }
  
  
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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