cooked_index_worker::done_reading ()
{
{
- scoped_time_it time_it ("DWARF add parent map");
+ scoped_time_it time_it ("DWARF add parent map", m_per_command_time);
for (auto &one_result : m_results)
m_all_parents_map.add_map (*one_result.get_parent_map ());
#include "dwarf2/cooked-index-shard.h"
#include "dwarf2/types.h"
#include "dwarf2/read.h"
+#include "maint.h"
+#include "run-on-main-thread.h"
#if CXX_STD_THREAD
#include <mutex>
explicit cooked_index_worker (dwarf2_per_objfile *per_objfile)
: m_per_objfile (per_objfile),
- m_cache_store (global_index_cache, per_objfile->per_bfd)
- { }
+ m_cache_store (global_index_cache, per_objfile->per_bfd),
+ m_per_command_time (per_command_time)
+ {
+ /* Make sure we capture per_command_time from the main thread. */
+ gdb_assert (is_main_thread ());
+ }
virtual ~cooked_index_worker ()
{ }
DISABLE_COPY_AND_ASSIGN (cooked_index_worker);
std::optional<gdb_exception> m_failed;
/* An object used to write to the index cache. */
index_cache_store_context m_cache_store;
+
+ /* Captured value of per_command_time. */
+ bool m_per_command_time;
};
using cooked_index_worker_up = std::unique_ptr<cooked_index_worker>;
const parent_map_map *parent_maps = m_state->get_parent_map_map ();
finalizers.add_task ([=] ()
{
- scoped_time_it time_it ("DWARF finalize worker");
+ scoped_time_it time_it ("DWARF finalize worker",
+ m_state->m_per_command_time);
this_shard->finalize (parent_maps);
});
}
cooked_index_worker_debug_info::process_skeletonless_type_units
(dwarf2_per_objfile *per_objfile, cooked_index_worker_result *storage)
{
- scoped_time_it time_it ("DWARF skeletonless type units");
+ scoped_time_it time_it ("DWARF skeletonless type units", m_per_command_time);
/* Skeletonless TUs in DWP files without .gdb_index is not supported yet. */
if (per_objfile->per_bfd->dwp_file == nullptr)
gdb_assert (iter != last);
workers.add_task ([this, task_count, iter, last] ()
{
- scoped_time_it time_it ("DWARF indexing worker");
+ scoped_time_it time_it ("DWARF indexing worker", m_per_command_time);
process_units (task_count, iter, last);
});
}
\f
-/* If true, display time usage both at startup and for each command. */
+/* See maint.h. */
-static bool per_command_time;
+bool per_command_time;
/* If true, display space usage both at startup and for each command. */
/* See maint.h. */
-scoped_time_it::scoped_time_it (const char *what)
- : m_enabled (per_command_time),
+scoped_time_it::scoped_time_it (const char *what, bool enabled)
+ : m_enabled (enabled),
m_what (what),
m_start_wall (m_enabled
? std::chrono::steady_clock::now ()
int m_start_nr_blocks;
};
+/* If true, display time usage both at startup and for each command. */
+
+extern bool per_command_time;
+
/* RAII structure used to measure the time spent by the current thread in a
given scope. */
struct scoped_time_it
{
/* WHAT is the prefix to show when the summary line is printed. */
- scoped_time_it (const char *what);
+ scoped_time_it (const char *what, bool enabled = per_command_time);
DISABLE_COPY_AND_ASSIGN (scoped_time_it);
~scoped_time_it ();