[Lldb-commits] [PATCH] D117474: [lldb] Make StatsDuration thread-safe

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jan 17 06:17:20 PST 2022


labath created this revision.
labath added a reviewer: clayborg.
Herald added a subscriber: arphaman.
labath requested review of this revision.
Herald added a project: LLDB.

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>).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117474

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117474.400511.patch
Type: text/x-patch
Size: 11089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220117/3158dbef/attachment-0001.bin>


More information about the lldb-commits mailing list