From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Victor Leschuk <vleschuk@accesssoftek.com>
Subject: [PATCH 5/6] Refactor: Move some generic code out of .gdb_index code
Date: Fri, 26 May 2017 18:26:00 -0000 [thread overview]
Message-ID: <149582316767.15869.7404458720264311648.stgit@host1.jankratochvil.net> (raw)
In-Reply-To: <149582312757.15869.18345460438195439402.stgit@host1.jankratochvil.net>
Hi,
just for the next patch.
Jan
gdb/ChangeLog
2017-05-26 Jan Kratochvil <jan.kratochvil@redhat.com>
* dwarf2read.c (create_cu_from_index_list): New from ...
(create_cus_from_index_list): ... this function, use it.
(dw_expand_symtabs_matching_file_matcher)
(dw2_expand_symtabs_matching_one): New from ...
(dw2_expand_symtabs_matching): ... this function, use them.
---
gdb/dwarf2read.c | 220 ++++++++++++++++++++++++++++++++----------------------
1 file changed, 130 insertions(+), 90 deletions(-)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index e7c3643..2823428 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2939,6 +2939,28 @@ dw2_get_cu (int index)
return dwarf2_per_objfile->all_comp_units[index];
}
+// Return newly allocated dwarf2_per_cu_data from objfile_obstack
+// with the specified field values.
+
+static dwarf2_per_cu_data *
+create_cu_from_index_list (struct objfile *objfile,
+ struct dwarf2_section_info *section,
+ int is_dwz,
+ sect_offset sect_off, ULONGEST length)
+{
+ dwarf2_per_cu_data *the_cu
+ = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_data);
+ the_cu->sect_off = sect_off;
+ the_cu->length = length;
+ the_cu->objfile = objfile;
+ the_cu->section = section;
+ the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct dwarf2_per_cu_quick_data);
+ the_cu->is_dwz = is_dwz;
+ return the_cu;
+}
+
/* A helper for create_cus_from_index that handles a given list of
CUs. */
@@ -2960,17 +2982,8 @@ create_cus_from_index_list (struct objfile *objfile,
ULONGEST length = extract_unsigned_integer (cu_list + 8, 8, BFD_ENDIAN_LITTLE);
cu_list += 2 * 8;
- dwarf2_per_cu_data *the_cu
- = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct dwarf2_per_cu_data);
- the_cu->sect_off = sect_off;
- the_cu->length = length;
- the_cu->objfile = objfile;
- the_cu->section = section;
- the_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct dwarf2_per_cu_quick_data);
- the_cu->is_dwz = is_dwz;
- dwarf2_per_objfile->all_comp_units[base_offset + i / 2] = the_cu;
+ dwarf2_per_objfile->all_comp_units[base_offset + i / 2] =
+ create_cu_from_index_list (objfile, section, is_dwz, sect_off, length);
}
}
@@ -4013,96 +4026,135 @@ dw2_map_matching_symbols (struct objfile *objfile,
does not look for non-Ada symbols this function should just return. */
}
+// If FILE_MATCHER is non-zero set for current DWARF2_PER_OBJFILE all
+// dwarf2_per_cu_quick_data::MARK matching FILE_MATCHER.
+
static void
-dw2_expand_symtabs_matching
- (struct objfile *objfile,
- gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
- gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
- gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
- enum search_domain kind)
+dw_expand_symtabs_matching_file_matcher
+ (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
{
- int i;
- offset_type iter;
- struct mapped_index *index;
+ objfile *const objfile (dwarf2_per_objfile->objfile);
- dw2_setup (objfile);
-
- /* index_table is NULL if OBJF_READNOW. */
- if (!dwarf2_per_objfile->index_table)
+ if (file_matcher == NULL)
return;
- index = dwarf2_per_objfile->index_table;
- if (file_matcher != NULL)
- {
- htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
+ htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
+ htab_eq_pointer,
+ NULL, xcalloc, xfree));
+ htab_up visited_not_found (htab_create_alloc (10, htab_hash_pointer,
htab_eq_pointer,
NULL, xcalloc, xfree));
- htab_up visited_not_found (htab_create_alloc (10, htab_hash_pointer,
- htab_eq_pointer,
- NULL, xcalloc, xfree));
- /* The rule is CUs specify all the files, including those used by
- any TU, so there's no need to scan TUs here. */
+ /* The rule is CUs specify all the files, including those used by
+ any TU, so there's no need to scan TUs here. */
- for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
- {
- int j;
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
- struct quick_file_names *file_data;
- void **slot;
+ for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+ {
+ int j;
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct quick_file_names *file_data;
+ void **slot;
- QUIT;
+ QUIT;
- per_cu->v.quick->mark = 0;
+ per_cu->v.quick->mark = 0;
- /* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->compunit_symtab)
- continue;
+ /* We only need to look at symtabs not already expanded. */
+ if (per_cu->v.quick->compunit_symtab)
+ continue;
- file_data = dw2_get_file_names (per_cu);
- if (file_data == NULL)
- continue;
+ file_data = dw2_get_file_names (per_cu);
+ if (file_data == NULL)
+ continue;
- if (htab_find (visited_not_found.get (), file_data) != NULL)
- continue;
- else if (htab_find (visited_found.get (), file_data) != NULL)
+ if (htab_find (visited_not_found.get (), file_data) != NULL)
+ continue;
+ else if (htab_find (visited_found.get (), file_data) != NULL)
+ {
+ per_cu->v.quick->mark = 1;
+ continue;
+ }
+
+ for (j = 0; j < file_data->num_file_names; ++j)
+ {
+ const char *this_real_name;
+
+ if (file_matcher (file_data->file_names[j], false))
{
per_cu->v.quick->mark = 1;
- continue;
+ break;
}
- for (j = 0; j < file_data->num_file_names; ++j)
+ /* Before we invoke realpath, which can get expensive when many
+ files are involved, do a quick comparison of the basenames. */
+ if (!basenames_may_differ
+ && !file_matcher (lbasename (file_data->file_names[j]),
+ true))
+ continue;
+
+ this_real_name = dw2_get_real_path (objfile, file_data, j);
+ if (file_matcher (this_real_name, false))
{
- const char *this_real_name;
+ per_cu->v.quick->mark = 1;
+ break;
+ }
+ }
- if (file_matcher (file_data->file_names[j], false))
- {
- per_cu->v.quick->mark = 1;
- break;
- }
+ slot = htab_find_slot (per_cu->v.quick->mark
+ ? visited_found.get ()
+ : visited_not_found.get (),
+ file_data, INSERT);
+ *slot = file_data;
+ }
+}
- /* Before we invoke realpath, which can get expensive when many
- files are involved, do a quick comparison of the basenames. */
- if (!basenames_may_differ
- && !file_matcher (lbasename (file_data->file_names[j]),
- true))
- continue;
+// If FILE_MATCHER is zero
+// or if PER_CU has dwarf2_per_cu_quick_data::MARK set
+// (see dw_expand_symtabs_matching_file_matcher) expand the CU
+// and call its EXPANSION_NOTIFY.
- this_real_name = dw2_get_real_path (objfile, file_data, j);
- if (file_matcher (this_real_name, false))
- {
- per_cu->v.quick->mark = 1;
- break;
- }
- }
+static void
+dw2_expand_symtabs_matching_one
+ (struct dwarf2_per_cu_data *per_cu,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify)
+{
+ if (file_matcher == NULL || per_cu->v.quick->mark)
+ {
+ int symtab_was_null =
+ (per_cu->v.quick->compunit_symtab == NULL);
+
+ dw2_instantiate_symtab (per_cu);
- slot = htab_find_slot (per_cu->v.quick->mark
- ? visited_found.get ()
- : visited_not_found.get (),
- file_data, INSERT);
- *slot = file_data;
+ if (expansion_notify != NULL
+ && symtab_was_null
+ && per_cu->v.quick->compunit_symtab != NULL)
+ {
+ expansion_notify (per_cu->v.quick->compunit_symtab);
}
}
+}
+
+static void
+dw2_expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ enum search_domain kind)
+{
+ int i;
+ offset_type iter;
+ struct mapped_index *index;
+
+ dw2_setup (objfile);
+
+ /* index_table is NULL if OBJF_READNOW. */
+ if (!dwarf2_per_objfile->index_table)
+ return;
+ index = dwarf2_per_objfile->index_table;
+
+ dw_expand_symtabs_matching_file_matcher (file_matcher);
for (iter = 0; iter < index->symbol_table_slots; ++iter)
{
@@ -4185,20 +4237,8 @@ dw2_expand_symtabs_matching
}
per_cu = dw2_get_cutu (cu_index);
- if (file_matcher == NULL || per_cu->v.quick->mark)
- {
- int symtab_was_null =
- (per_cu->v.quick->compunit_symtab == NULL);
-
- dw2_instantiate_symtab (per_cu);
-
- if (expansion_notify != NULL
- && symtab_was_null
- && per_cu->v.quick->compunit_symtab != NULL)
- {
- expansion_notify (per_cu->v.quick->compunit_symtab);
- }
- }
+ dw2_expand_symtabs_matching_one (per_cu, file_matcher,
+ expansion_notify);
}
}
}
next prev parent reply other threads:[~2017-05-26 18:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-26 18:25 [PATCH 0/6] DWARF-5: .debug_names index Jan Kratochvil
2017-05-26 18:25 ` [PATCH 2/6] cc-with-tweaks.sh: Use gdb-add-index.sh Jan Kratochvil
2017-05-26 18:25 ` [PATCH 1/6] Code cleanup: C++ify .gdb_index producer Jan Kratochvil
2017-06-12 16:08 ` [pushed] " Pedro Alves
2017-06-12 16:14 ` [PATCH 1/6] Code cleanup: dwarf2read.c:uniquify_cu_indices: Use std::unique Pedro Alves
2017-06-12 16:14 ` [PATCH 2/6] Code cleanup: dwarf2read.c: Eliminate ::file_write Pedro Alves
2017-06-17 17:35 ` Jan Kratochvil
2017-06-19 9:26 ` Pedro Alves
2017-06-18 18:36 ` Regression: " Jan Kratochvil
2017-06-19 9:27 ` Pedro Alves
2017-06-19 9:39 ` Jan Kratochvil
2017-06-19 9:47 ` Pedro Alves
2017-06-19 10:03 ` Jan Kratochvil
2017-06-19 10:35 ` Pedro Alves
2017-06-19 12:06 ` Yao Qi
2017-06-19 12:26 ` Jan Kratochvil
2017-06-12 16:14 ` [PATCH 3/6] Code cleanup: dwarf2read.c: Add data_buf::append_uint Pedro Alves
2017-06-12 16:14 ` [PATCH 4/6] .gdb_index prod perf regression: find before insert in unordered_map Pedro Alves
2017-06-12 16:14 ` [PATCH 6/6] .gdb_index prod perf regression: mapped_symtab now vector of values Pedro Alves
2017-06-12 16:18 ` [pushed] Re: [PATCH 1/6] Code cleanup: C++ify .gdb_index producer Pedro Alves
2017-06-12 16:19 ` [PATCH 5/6] .gdb_index prod perf regression: Estimate size of psyms_seen Pedro Alves
2017-06-18 14:25 ` [pushed] Re: [PATCH 1/6] Code cleanup: C++ify .gdb_index producer Jan Kratochvil
2017-06-18 15:12 ` Eli Zaretskii
2017-06-19 11:50 ` [pushed] .gdb_index writer: close the file before unlinking it (Re: [pushed] Re: [PATCH 1/6] Code cleanup: C++ify .gdb_index producer.) Pedro Alves
2017-06-18 16:50 ` [pushed] Re: [PATCH 1/6] Code cleanup: C++ify .gdb_index producer Jan Kratochvil
2017-05-26 18:26 ` [PATCH 3/6] DWARF-5: .debug_names index producer Jan Kratochvil
2017-06-09 5:58 ` [PATCH 3.1/6] " Jan Kratochvil
2017-05-26 18:26 ` Jan Kratochvil [this message]
2017-05-26 18:26 ` [PATCH 6/6] DWARF-5: .debug_names index consumer Jan Kratochvil
2017-05-26 18:26 ` [PATCH 4/6] Code cleanup: dwarf2_initialize_objfile return value Jan Kratochvil
2017-06-18 19:37 ` obsolete: [PATCH 0/6] DWARF-5: .debug_names index Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=149582316767.15869.7404458720264311648.stgit@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=vleschuk@accesssoftek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).