View | Details | Raw Unified
Collapse All | Expand All

(-) gdb-6.2.1-orig/gdb/dwarf2read.c (-15 / +38 lines)
 Lines 757-763    Link Here 
static struct line_header *(dwarf_decode_line_header
static struct line_header *(dwarf_decode_line_header
                            (unsigned int offset,
                            (unsigned int offset,
                             bfd *abfd, struct dwarf2_cu *cu));
                             bfd *abfd, struct dwarf2_cu *cu, const char* comp_dir));
static void dwarf_decode_lines (struct line_header *, char *, bfd *,
static void dwarf_decode_lines (struct line_header *, char *, bfd *,
				struct dwarf2_cu *, struct partial_symtab *);
				struct dwarf2_cu *, struct partial_symtab *);
 Lines 1262-1268    Link Here 
  bfd *abfd = objfile->obfd;
  bfd *abfd = objfile->obfd;
  struct line_header *lh;
  struct line_header *lh;
  lh = dwarf_decode_line_header (pdi->line_offset, abfd, cu);
  lh = dwarf_decode_line_header (pdi->line_offset, abfd, cu, pst->dirname);
  if (lh == NULL)
  if (lh == NULL)
    return;  /* No linetable, so no includes.  */
    return;  /* No linetable, so no includes.  */
 Lines 2397-2403    Link Here 
  if (attr)
  if (attr)
    {
    {
      unsigned int line_offset = DW_UNSND (attr);
      unsigned int line_offset = DW_UNSND (attr);
      line_header = dwarf_decode_line_header (line_offset, abfd, cu);
      line_header = dwarf_decode_line_header (line_offset, abfd, cu, comp_dir);
      if (line_header)
      if (line_header)
        {
        {
          make_cleanup ((make_cleanup_ftype *) free_line_header,
          make_cleanup ((make_cleanup_ftype *) free_line_header,
 Lines 5665-5670    Link Here 
    return follow_die_ref (dwarf2_get_ref_die_offset (spec_attr, cu));
    return follow_die_ref (dwarf2_get_ref_die_offset (spec_attr, cu));
}
}
/* Create full path name from absolute and relative parts.
   The result string should be freed by caller when necessary. */
static char*
make_full_path (const char *full_part, const char *rel_part)
{
  char *result;
  int dir_len = strlen(full_part);
  result = xmalloc(dir_len + 1 + strlen(rel_part) + 1);
  strcpy (result, full_part);
  result[dir_len] = '/';
  strcpy (result + dir_len + 1, rel_part);
  return result;
}
/* Free the line_header structure *LH, and any arrays and strings it
/* Free the line_header structure *LH, and any arrays and strings it
   refers to.  */
   refers to.  */
static void
static void
 Lines 5678-5684    Link Here 
  if (lh->file_names)
  if (lh->file_names)
    xfree (lh->file_names);
    xfree (lh->file_names);
  /* Similarly for the include directory names.  */
  /* Similarly for the include directory names - they will be freed independently.  */
  if (lh->include_dirs)
  if (lh->include_dirs)
    xfree (lh->include_dirs);
    xfree (lh->include_dirs);
 Lines 5685-5695    Link Here 
  xfree (lh);
  xfree (lh);
}
}
/* Add an entry to LH's include directory table.  */
/* Add an entry to LH's include directory table.  */
static void
static void
add_include_dir (struct line_header *lh, char *include_dir)
add_include_dir (struct line_header *lh, char *include_dir, const char *comp_dir)
{
{
  char* real_dir;
  /* Grow the array if necessary.  */
  /* Grow the array if necessary.  */
  if (lh->include_dirs_size == 0)
  if (lh->include_dirs_size == 0)
    {
    {
 Lines 5705-5711    Link Here 
                                    * sizeof (*lh->include_dirs)));
                                    * sizeof (*lh->include_dirs)));
    }
    }
  lh->include_dirs[lh->num_include_dirs++] = include_dir;
  if (!IS_ABSOLUTE_PATH(include_dir) && comp_dir != NULL)
    {
      real_dir = make_full_path(comp_dir, include_dir);
      make_cleanup(xfree, real_dir);
    }
  else
    {
      real_dir = include_dir;
    }
  lh->include_dirs[lh->num_include_dirs++] = real_dir;
}
}
 
 
 Lines 5752-5758    Link Here 
   freed.  */
   freed.  */
static struct line_header *
static struct line_header *
dwarf_decode_line_header (unsigned int offset, bfd *abfd,
dwarf_decode_line_header (unsigned int offset, bfd *abfd,
			  struct dwarf2_cu *cu)
			  struct dwarf2_cu *cu, const char* comp_dir)
{
{
  struct cleanup *back_to;
  struct cleanup *back_to;
  struct line_header *lh;
  struct line_header *lh;
 Lines 5820-5826    Link Here 
  while ((cur_dir = read_string (abfd, line_ptr, &bytes_read)) != NULL)
  while ((cur_dir = read_string (abfd, line_ptr, &bytes_read)) != NULL)
    {
    {
      line_ptr += bytes_read;
      line_ptr += bytes_read;
      add_include_dir (lh, cur_dir);
      add_include_dir (lh, cur_dir, comp_dir);
    }
    }
  line_ptr += bytes_read;
  line_ptr += bytes_read;
 Lines 8292-8303    Link Here 
      if (dir)
      if (dir)
        {
        {
          dir_len = strlen (dir);
          return make_full_path(dir, fe->name);
          full_name = xmalloc (dir_len + 1 + strlen (fe->name) + 1);
          strcpy (full_name, dir);
          full_name[dir_len] = '/';
          strcpy (full_name + dir_len + 1, fe->name);
          return full_name;
        }
        }
      else
      else
        return xstrdup (fe->name);
        return xstrdup (fe->name);