Files
third_party_elfutils/libdw/dwarf_macro_param2.c
T
Petr Machata fb90bf3f84 Support .debug_macro
- This code is based on the following proposal:
    http://www.dwarfstd.org/ShowIssue.php?issue=110722.1

- dwarf_getmacros serves either of .debug_macinfo or .debug_macro
  transparently, but if the latter uses opcode 0xff, it bails out with
  an error.  The reason is that in .debug_macro, 0xff is a custom code
  that can mean anything, while in .debug_macinfo there's fixed
  semantics associated with 0xff.

- dwarf_getmacros_off is a new interface used for requesting iteration
  through transparently included units.

- dwarf_macro_getparamcnt and dwarf_macro_param are new interfaces
  used for requesting number of parameters of an opcode and individual
  parameters.  dwarf_macro_getsrcfiles is a new interface used for
  requesting a file part of .debug_line unit associated with macro
  unit that the opcode comes from.

- The existing interfaces dwarf_macro_opcode, dwarf_macro_param1 and
  dwarf_macro_param2 remain operational for old- as well as new-style
  Dwarf macro sections, if applicable.

- dwarf_getsrclines was made into a light wrapper around a worker
  function that loads line unit given its offset.  The worker also
  caches loaded units in an offset-keyed search tree, so that we don't
  end up re-reading units even though they were read in a different
  domain (e.g. a macro unit request can prime cache for later CU
  lookup).  dwarf_macro_getsrcfiles calls the worker function under
  covers.

Signed-off-by: Petr Machata <pmachata@redhat.com>
2014-11-10 15:45:00 +01:00

56 lines
1.5 KiB
C

/* Return second macro parameter.
Copyright (C) 2005, 2014 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2005.
This file is free software; you can redistribute it and/or modify
it under the terms of either
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at
your option) any later version
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at
your option) any later version
or both in parallel, as here.
elfutils is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "libdwP.h"
int
dwarf_macro_param2 (Dwarf_Macro *macro, Dwarf_Word *paramp, const char **strp)
{
if (macro == NULL)
return -1;
Dwarf_Attribute param;
if (dwarf_macro_param (macro, 1, &param) != 0)
return -1;
if (param.form == DW_FORM_string
|| param.form == DW_FORM_strp)
{
*strp = dwarf_formstring (&param);
return 0;
}
else
return dwarf_formudata (&param, paramp);
}