[lldb-dev] [RFC] Simplifying logging code

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Thu Aug 13 09:53:16 PDT 2015


There are also a few competing log implementations. There are ones like in "source/Core/Logging.cpp" which are hard coded, and then there is a plugin version as you can see in LogChannelDWARF.cpp. The latter is the newer way to implement custom log channels without hand coding a copy of "source/Core/Logging.cpp" for your uses. Code that uses "source/Core/Logging.cpp" was never ported to the new plugin version of logging because it was just busy work that would organize the code a bit better, but do nothing functionally to improve anything.

So if we do make changes we would move over to using the plugin version from "source/Core/Log.cpp" and add any macros or useful things to "include/lldb/Core/Log.h".

Greg

> On Aug 13, 2015, at 3:03 AM, Tamas Berghammer via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> 
> Thank you for the link to the previous discussion and the description of the Windows logging. I like the idea of the macro based logging on Windows but agree that the explicit log channel definition is a bit too verbose.
> 
> Currently I would prefer a mixed solution with 'Log* log = ...; LOG_IF(log, "pattern", ...);' for the usual case and 'Log* log = ...; LOG_IF_ANY(log, categories, "pattern", ...);' if we want to log to different log channels. I believe it will improve the readability quite a lot, but would only make sense if we can apply it to the full code base within a reasonably short period of time to avoid confusion with the multiple log patterns.
> 
> Tamas
> 
> On Wed, Aug 12, 2015 at 7:00 PM Zachary Turner via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> After the previous discussion I agree that evaluating the arguments is unacceptable.  But you are correct here that a macro would solve this.  In fact, most C++ log libraries use macros I guess for this very reason.  
> 
> I decided to make some macros for the windows plugin which you can look at it in ProcessWindowsLog.h.
> 
> There are some issues that are not obvious how to solve though.  For example, the macros I wrote in ProcessWindowsLog cannot be used outside of my plugin.  This is because each plugin statically defines its own channels as well as defines its own global Log object.  If this were to be done in a way that there were one set of macros that all current and future generic code and plugins could use, I think it would require a fairly substantial refactor.
> 
> On Wed, Aug 12, 2015 at 6:11 AM Vince Harron via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> We could solve booth the efficiency concerns and the conciseness with a macro.  (Gasp!)
> 
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev



More information about the lldb-dev mailing list