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]
Other format: [Raw text]

Re: RFA: ia64 portion of libunwind patch


On Oct 23,  8:11pm, J. Johnston wrote:

> Ok to commit?  Questions regarding this in conjunction with the generic 
> libunwind frame code?

> +#ifdef HAVE_LIBUNWIND_IA64_H
> +
> +# ifndef __NR_getunwind
> +#  define __NR_getunwind	1215
> +# endif

Is this part still needed?

                        ...........

> +static void *
> +map_segment (bfd *bfd, Elf_Internal_Phdr *p_text, struct map_info *mi)
> +  {
> +  size_t page_mask = getpagesize () - 1, nbytes;
> +  char *buf, *cp;
> +  ssize_t nread;
> +  int fd;
> +  
> +  if (bfd->iostream)
> +    fd = fileno (bfd->iostream);
> +  else
> +    fd = open (bfd_get_filename (bfd), O_RDONLY);
> +  
> +  if (fd < 0)
> +    return NULL;
> +
> +  buf = mmap (0, p_text->p_filesz, PROT_READ, MAP_PRIVATE, fd,
> +	      p_text->p_offset & ~page_mask);
> +  if (buf != (char *) -1)
> +    {
> +      mi->buf = buf;
> +      mi->length = p_text->p_filesz;
> +      mi->mapped = 1;
> +      buf += p_text->p_offset & page_mask;
> +    }
> +  else
> +    {
> +      /* mmap () failed, try reading the file: */
> +      mi->mapped = 0;
> +      
> +      if (lseek (fd, p_text->p_offset, SEEK_SET) < 0)
> +	{
> +	  if (!bfd->iostream)
> +	    close (fd);
> +	  return NULL;
> +	}
> +      
> +      nbytes = p_text->p_filesz;
> +      cp = buf = xmalloc (nbytes);
> +      while ((nbytes > 0) && (nread = read (fd, cp, nbytes)) > 0)
> +	{
> +	  cp += nread;
> +	  nbytes -= nread;
> +  	}
> +      if (nbytes > 0)
> +	{
> +	  /* premature end-of-file or some error */
> +	  xfree (buf);
> +	  buf = 0;
> +	}
> +      mi->buf = buf;
> +    }
> +  if (!bfd->iostream)
> +    close (fd);
> +  
> +  return buf;
> +}

For the above, why isn't bfd being employed to read the segment?

Kevin


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