Blame libdwfl/dwfl_lineinfo.c

Packit Service 97d2fb
/* Get information from a source line record returned by libdwfl.
Packit Service 97d2fb
   Copyright (C) 2005-2010, 2015 Red Hat, Inc.
Packit Service 97d2fb
   This file is part of elfutils.
Packit Service 97d2fb
Packit Service 97d2fb
   This file is free software; you can redistribute it and/or modify
Packit Service 97d2fb
   it under the terms of either
Packit Service 97d2fb
Packit Service 97d2fb
     * the GNU Lesser General Public License as published by the Free
Packit Service 97d2fb
       Software Foundation; either version 3 of the License, or (at
Packit Service 97d2fb
       your option) any later version
Packit Service 97d2fb
Packit Service 97d2fb
   or
Packit Service 97d2fb
Packit Service 97d2fb
     * the GNU General Public License as published by the Free
Packit Service 97d2fb
       Software Foundation; either version 2 of the License, or (at
Packit Service 97d2fb
       your option) any later version
Packit Service 97d2fb
Packit Service 97d2fb
   or both in parallel, as here.
Packit Service 97d2fb
Packit Service 97d2fb
   elfutils is distributed in the hope that it will be useful, but
Packit Service 97d2fb
   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 97d2fb
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 97d2fb
   General Public License for more details.
Packit Service 97d2fb
Packit Service 97d2fb
   You should have received copies of the GNU General Public License and
Packit Service 97d2fb
   the GNU Lesser General Public License along with this program.  If
Packit Service 97d2fb
   not, see <http://www.gnu.org/licenses/>.  */
Packit Service 97d2fb
Packit Service 97d2fb
#ifdef HAVE_CONFIG_H
Packit Service 97d2fb
# include <config.h>
Packit Service 97d2fb
#endif
Packit Service 97d2fb
Packit Service 97d2fb
#include "libdwflP.h"
Packit Service 97d2fb
#include "../libdw/libdwP.h"
Packit Service 97d2fb
Packit Service 97d2fb
const char *
Packit Service 97d2fb
dwfl_lineinfo (Dwfl_Line *line, Dwarf_Addr *addr, int *linep, int *colp,
Packit Service 97d2fb
	       Dwarf_Word *mtime, Dwarf_Word *length)
Packit Service 97d2fb
{
Packit Service 97d2fb
  if (line == NULL)
Packit Service 97d2fb
    return NULL;
Packit Service 97d2fb
Packit Service 97d2fb
  struct dwfl_cu *cu = dwfl_linecu (line);
Packit Service 97d2fb
  const Dwarf_Line *info = &cu->die.cu->lines->info[line->idx];
Packit Service 97d2fb
Packit Service 97d2fb
  if (addr != NULL)
Packit Service 97d2fb
    *addr = dwfl_adjusted_dwarf_addr (cu->mod, info->addr);
Packit Service 97d2fb
  if (linep != NULL)
Packit Service 97d2fb
    *linep = info->line;
Packit Service 97d2fb
  if (colp != NULL)
Packit Service 97d2fb
    *colp = info->column;
Packit Service 97d2fb
Packit Service 97d2fb
  if (unlikely (info->file >= info->files->nfiles))
Packit Service 97d2fb
    {
Packit Service 97d2fb
      __libdwfl_seterrno (DWFL_E (LIBDW, DWARF_E_INVALID_DWARF));
Packit Service 97d2fb
      return NULL;
Packit Service 97d2fb
    }
Packit Service 97d2fb
Packit Service 97d2fb
  struct Dwarf_Fileinfo_s *file = &info->files->info[info->file];
Packit Service 97d2fb
  if (mtime != NULL)
Packit Service 97d2fb
    *mtime = file->mtime;
Packit Service 97d2fb
  if (length != NULL)
Packit Service 97d2fb
    *length = file->length;
Packit Service 97d2fb
  return file->name;
Packit Service 97d2fb
}