[all-commits] [llvm/llvm-project] 4f8915: [lldb] Make StatsDuration thread-safe

Pavel Labath via All-commits all-commits at lists.llvm.org
Wed Jan 19 07:43:13 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4f89157b9d73711a7ce20b597f93eb17a3133adf
      https://github.com/llvm/llvm-project/commit/4f89157b9d73711a7ce20b597f93eb17a3133adf
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2022-01-19 (Wed, 19 Jan 2022)

  Changed paths:
    M lldb/include/lldb/Breakpoint/Breakpoint.h
    M lldb/include/lldb/Core/Module.h
    M lldb/include/lldb/Symbol/SymbolFile.h
    M lldb/include/lldb/Target/Statistics.h
    M lldb/source/Breakpoint/Breakpoint.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
    M lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    M lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    M lldb/source/Target/Statistics.cpp

  Log Message:
  -----------
  [lldb] Make StatsDuration thread-safe

std::chrono::duration types are not thread-safe, and they cannot be
concurrently updated from multiple threads. Currently, we were doing
such a thing (only) in the DWARF indexing code
(DWARFUnit::ExtractDIEsRWLocked), but I think it can easily happen that
someone else tries to update another statistic like this without
bothering to check for thread safety.

This patch changes the StatsDuration type from a simple typedef into a
class in its own right. The class stores the duration internally as
std::atomic<uint64_t> (so it can be updated atomically), but presents it
to its users as the usual chrono type (duration<float>).

Differential Revision: https://reviews.llvm.org/D117474




More information about the All-commits mailing list