[all-commits] [llvm/llvm-project] 0f08db: [lldb] Make logging machinery type-safe

Pavel Labath via All-commits all-commits at lists.llvm.org
Tue Jan 25 03:14:15 PST 2022


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

  Changed paths:
    M lldb/include/lldb/Interpreter/ScriptedInterface.h
    M lldb/include/lldb/Utility/Log.h
    M lldb/include/lldb/Utility/Logging.h
    M lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
    M lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
    M lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
    M lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
    M lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
    M lldb/source/Utility/Log.cpp
    M lldb/source/Utility/Logging.cpp
    M lldb/tools/lldb-server/lldb-gdbserver.cpp
    M lldb/unittests/Utility/LogTest.cpp

  Log Message:
  -----------
  [lldb] Make logging machinery type-safe

This patch makes use of c++ type checking and scoped enums to make
logging statements shorter and harder to misuse.

Defines like LIBLLDB_LOG_PROCESS are replaces with LLDBLog::Process.
Because it now carries type information we do not need to worry about
matching a specific enum value with the right getter function -- the
compiler will now do that for us.

The main entry point for the logging machinery becomes the GetLog
(template) function, which will obtain the correct Log object based on
the enum type. It achieves this through another template function
(LogChannelFor<T>), which must be specialized for each type, and should
return the appropriate channel object.

This patch also removes the ability to log a message if multiple
categories are enabled simultaneously as it was unused and confusing.

This patch does not actually remove any of the existing interfaces. The
defines and log retrieval functions are left around as wrappers around
the new interfaces. They will be removed in follow-up patch.

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


  Commit: ce6903595b7161f881b62834c55b3099853cabd5
      https://github.com/llvm/llvm-project/commit/ce6903595b7161f881b62834c55b3099853cabd5
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2022-01-25 (Tue, 25 Jan 2022)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/dotest.py

  Log Message:
  -----------
  [lldb/test] Use abspath when searching for lldb.exe

realpath is too aggressive and does not produce the desired effect if
ones build folder is a symlink farm.


Compare: https://github.com/llvm/llvm-project/compare/7cb452bfde10...ce6903595b71


More information about the All-commits mailing list