X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libdw%2Fdwarf_getscopevar.c;h=7b1416f3a24d75e286eab0b9955897e6749cfa9e;hb=82c3b58b54026d061a4d81ad95f3023d5d883ab2;hp=eb50c0adfef89c19f630953b4dfbfdafe1d9cdb9;hpb=a286dd013ef8d46edf013efc0908822a59d8ac81;p=platform%2Fupstream%2Felfutils.git diff --git a/libdw/dwarf_getscopevar.c b/libdw/dwarf_getscopevar.c index eb50c0a..7b1416f 100644 --- a/libdw/dwarf_getscopevar.c +++ b/libdw/dwarf_getscopevar.c @@ -52,6 +52,26 @@ getattr (Dwarf_Die *die, int search_name, Dwarf_Word *value) &attr_mem), value); } +static inline int +file_matches (const char *lastfile, + size_t match_file_len, const char *match_file, + Dwarf_Files *files, size_t idx, + bool *lastfile_matches) +{ + if (idx >= files->nfiles) + return false; + const char *file = files->info[idx].name; + if (file != lastfile) + { + size_t len = strlen (file); + *lastfile_matches = (len >= match_file_len + && !memcmp (match_file, file, match_file_len) + && (len == match_file_len + || file[len - match_file_len - 1] == '/')); + } + return *lastfile_matches; +} + /* Search SCOPES[0..NSCOPES-1] for a variable called NAME. Ignore the first SKIP_SHADOWS scopes that match the name. If MATCH_FILE is not null, accept only declaration in that source file; @@ -72,22 +92,6 @@ dwarf_getscopevar (Dwarf_Die *scopes, int nscopes, size_t match_file_len = match_file == NULL ? 0 : strlen (match_file); bool lastfile_matches = false; const char *lastfile = NULL; - inline bool file_matches (Dwarf_Files *files, size_t idx) - { - if (idx >= files->nfiles) - return false; - - const char *file = files->info[idx].name; - if (file != lastfile) - { - size_t len = strlen (file); - lastfile_matches = (len >= match_file_len - && !memcmp (match_file, file, match_file_len) - && (len == match_file_len - || file[len - match_file_len - 1] == '/')); - } - return lastfile_matches; - } /* Start with the innermost scope and move out. */ for (int out = 0; out < nscopes; ++out) @@ -130,7 +134,8 @@ dwarf_getscopevar (Dwarf_Die *scopes, int nscopes, || getfiles (&scopes[out], &files) != 0) break; - if (!file_matches (files, i)) + if (!file_matches (lastfile, match_file_len, match_file, + files, i, &lastfile_matches)) break; if (match_lineno > 0