Please use attached 0002*patch file,
which added my missing email address in the signed-off line.
Thanks.



On Wed, Oct 21, 2015 at 3:50 PM, Chih-Hung Hsieh <c...@google.com> wrote:

> * Nested functions in these two files are moved to file scope
>   to compile with clang. Extra parameters are added to pass
>   local variables.
>
> Signed-off-by: Chih-Hung Hsieh
> ---
>  libdwfl/ChangeLog                 |  7 +++++++
>  libdwfl/dwfl_module.c             | 33 +++++++++++++++++----------------
>  libdwfl/dwfl_module_getsrc_file.c | 31 ++++++++++++++++++-------------
>  3 files changed, 42 insertions(+), 29 deletions(-)
>
> diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
> index 5cae434..0374e5a 100644
> --- a/libdwfl/ChangeLog
> +++ b/libdwfl/ChangeLog
> @@ -1,3 +1,10 @@
> +2015-10-21  Chih-Hung Hsieh <c...@google.com>
> +
> +       * dwfl_module.c (dwfl_report_module): Move nested function 'use'
> to file
> +       scope.
> +       * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Move nested
> functions
> +       'dwarf_line_file', 'dwfl_line', and 'dwfl_line_file' to file scope.
> +
>  2015-10-09  Josh Stone  <jist...@redhat.com>
>
>         * core-file.c (elf_begin_rand): Replace loff_t with off_t.
> diff --git a/libdwfl/dwfl_module.c b/libdwfl/dwfl_module.c
> index 8efcfaa..76d45a8 100644
> --- a/libdwfl/dwfl_module.c
> +++ b/libdwfl/dwfl_module.c
> @@ -125,6 +125,21 @@ dwfl_report_begin (Dwfl *dwfl)
>  }
>  INTDEF (dwfl_report_begin)
>
> +static inline Dwfl_Module *
> +use (Dwfl_Module *mod, Dwfl_Module **tailp, Dwfl *dwfl)
> +{
> +  mod->next = *tailp;
> +  *tailp = mod;
> +
> +  if (unlikely (dwfl->lookup_module != NULL))
> +    {
> +      free (dwfl->lookup_module);
> +      dwfl->lookup_module = NULL;
> +    }
> +
> +  return mod;
> +}
> +
>  /* Report that a module called NAME spans addresses [START, END).
>     Returns the module handle, either existing or newly allocated,
>     or returns a null pointer for an allocation error.  */
> @@ -134,20 +149,6 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
>  {
>    Dwfl_Module **tailp = &dwfl->modulelist, **prevp = tailp;
>
> -  inline Dwfl_Module *use (Dwfl_Module *mod)
> -  {
> -    mod->next = *tailp;
> -    *tailp = mod;
> -
> -    if (unlikely (dwfl->lookup_module != NULL))
> -      {
> -       free (dwfl->lookup_module);
> -       dwfl->lookup_module = NULL;
> -      }
> -
> -    return mod;
> -  }
> -
>    for (Dwfl_Module *m = *prevp; m != NULL; m = *(prevp = &m->next))
>      {
>        if (m->low_addr == start && m->high_addr == end
> @@ -157,7 +158,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
>              after the last module already reported.  */
>           *prevp = m->next;
>           m->gc = false;
> -         return use (m);
> +         return use (m, tailp, dwfl);
>         }
>
>        if (! m->gc)
> @@ -181,7 +182,7 @@ dwfl_report_module (Dwfl *dwfl, const char *name,
>    mod->high_addr = end;
>    mod->dwfl = dwfl;
>
> -  return use (mod);
> +  return use (mod, tailp, dwfl);
>  }
>  INTDEF (dwfl_report_module)
>
> diff --git a/libdwfl/dwfl_module_getsrc_file.c
> b/libdwfl/dwfl_module_getsrc_file.c
> index 20aa8a5..75ba68e 100644
> --- a/libdwfl/dwfl_module_getsrc_file.c
> +++ b/libdwfl/dwfl_module_getsrc_file.c
> @@ -30,6 +30,24 @@
>  #include "../libdw/libdwP.h"
>
>
> +static inline const char *
> +INTUSE(dwarf_line_file) (const Dwarf_Line *line)
> +{
> +  return line->files->info[line->file].name;
> +}
> +
> +static inline Dwarf_Line *
> +dwfl_line (const Dwfl_Line *line)
> +{
> +  return &dwfl_linecu (line)->die.cu->lines->info[line->idx];
> +}
> +
> +static inline const char *
> +dwfl_line_file (const Dwfl_Line *line)
> +{
> +  return INTUSE(dwarf_line_file) (dwfl_line (line));
> +}
> +
>  int
>  dwfl_module_getsrc_file (Dwfl_Module *mod,
>                          const char *fname, int lineno, int column,
> @@ -58,19 +76,6 @@ dwfl_module_getsrc_file (Dwfl_Module *mod,
>          && cu != NULL
>          && (error = __libdwfl_cu_getsrclines (cu)) == DWFL_E_NOERROR)
>      {
> -      inline const char *INTUSE(dwarf_line_file) (const Dwarf_Line *line)
> -       {
> -         return line->files->info[line->file].name;
> -       }
> -      inline Dwarf_Line *dwfl_line (const Dwfl_Line *line)
> -       {
> -         return &dwfl_linecu (line)->die.cu->lines->info[line->idx];
> -       }
> -      inline const char *dwfl_line_file (const Dwfl_Line *line)
> -       {
> -         return INTUSE(dwarf_line_file) (dwfl_line (line));
> -       }
> -
>        /* Search through all the line number records for a matching
>          file and line/column number.  If any of the numbers is zero,
>          no match is performed.  */
> --
> 2.6.0.rc2.230.g3dd15c0
>
>

Attachment: 0002-Move-nested-functions-in-dwfl_module.c-and-dwfl_modu.patch
Description: Binary data

Reply via email to