Bug 177459 - [CMake] ENABLE(DEVELOPER_MODE) should enable logging support for Release builds.
Summary: [CMake] ENABLE(DEVELOPER_MODE) should enable logging support for Release builds.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Carlos Alberto Lopez Perez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-25 13:17 PDT by Carlos Alberto Lopez Perez
Modified: 2018-06-18 00:45 PDT (History)
17 users (show)

See Also:


Attachments
Patch (1.36 KB, patch)
2018-01-17 06:56 PST, Carlos Alberto Lopez Perez
no flags Details | Formatted Diff | Diff
Patch (1.24 KB, patch)
2018-01-17 10:48 PST, Carlos Alberto Lopez Perez
no flags Details | Formatted Diff | Diff
Patch (2.12 KB, patch)
2018-01-17 12:51 PST, Carlos Alberto Lopez Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Alberto Lopez Perez 2017-09-25 13:17:10 PDT
Currently if one wants to enable WebKit logging support it has to use Debug builds or pass manually the flag with something like CXXFLAGS="-DLOG_DISABLED=0"

Its actually documented here: https://trac.webkit.org/wiki/WebKitGTK/Debugging#Loggingsupport


For debug builds, logging is enabled at build-time but disabled by default at run-time.
To enable it at run-time the environment variable WEBKIT_DEBUG should be set to the right value

And for release builds I think it makes sense to do the same when ENABLE(DEVELOPER_MODE) is set (enable it at build-time).


Its bit of a pain not being able to have logging support in release development builds.
Comment 1 Michael Catanzaro 2017-09-25 13:57:53 PDT
It should also enable asserts (but we're not quite ready for that yet)
Comment 2 Carlos Alberto Lopez Perez 2018-01-17 06:56:41 PST
Created attachment 331491 [details]
Patch
Comment 3 Konstantin Tokarev 2018-01-17 07:00:44 PST
This may result in different performance of developer and non-developer release builds. Using -DRELEASE_LOG_DISABLED=0 should be safer
Comment 4 Carlos Alberto Lopez Perez 2018-01-17 07:18:31 PST
(In reply to Konstantin Tokarev from comment #3)
> This may result in different performance of developer and non-developer
> release builds.

I don't think this will impact performance in any sensible way. The feature is disabled at runtime by default, you have to set the environment variable WEBKIT_DEBUG to enable it.


> Using -DRELEASE_LOG_DISABLED=0 should be safer


RELEASE_LOG_DISABLED is another complete different thing not supported in the CMake ports (GTK and WPE currently). It uses os_log() which is only supported on Mac. Check https://developer.apple.com/documentation/os/os_log and bug 160969 that introduced it
Comment 5 Michael Catanzaro 2018-01-17 09:01:22 PST
Comment on attachment 331491 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=331491&action=review

> Source/cmake/OptionsCommon.cmake:99
> +if (DEVELOPER_MODE)
> +    # Explicit enable logging support (ensures its also enabled on release development builds).
> +    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOG_DISABLED=0")
> +endif ()

Can you find a better way to do this? What is setting LOG_DISABLED in the first place?
Comment 6 Konstantin Tokarev 2018-01-17 09:02:48 PST
// wtf/Assertions.h

#ifndef LOG_DISABLED
#define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT
#endif
Comment 7 Konstantin Tokarev 2018-01-17 09:07:12 PST
(In reply to Carlos Alberto Lopez Perez from comment #4)
> RELEASE_LOG_DISABLED is another complete different thing not supported in
> the CMake ports (GTK and WPE currently). It uses os_log() which is only
> supported on Mac. Check https://developer.apple.com/documentation/os/os_log
> and bug 160969 that introduced it

We could define RELEASE_LOG macros to use "normal" logging. Though for me personally it would be really nice to see ltt-ng's tracelog() support built-in :)
Comment 8 Konstantin Tokarev 2018-01-17 09:10:07 PST
(In reply to Michael Catanzaro from comment #1)
> It should also enable asserts (but we're not quite ready for that yet)

Are you really ready to fix all WebCore assertion as they pop up when sites change their content?
Comment 9 Carlos Alberto Lopez Perez 2018-01-17 09:32:04 PST
(In reply to Michael Catanzaro from comment #5)
> Comment on attachment 331491 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=331491&action=review
> 
> > Source/cmake/OptionsCommon.cmake:99
> > +if (DEVELOPER_MODE)
> > +    # Explicit enable logging support (ensures its also enabled on release development builds).
> > +    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOG_DISABLED=0")
> > +endif ()
> 
> Can you find a better way to do this? What is setting LOG_DISABLED in the
> first place?

I don't think there is a better way to do this.
On debug mode DLOG_DISABLED=0 gets set on the header because cmake defines -DNDEBUG=1

Can you please remove the r-?
Comment 10 Carlos Alberto Lopez Perez 2018-01-17 09:33:10 PST
(In reply to Konstantin Tokarev from comment #7)
> (In reply to Carlos Alberto Lopez Perez from comment #4)
> > RELEASE_LOG_DISABLED is another complete different thing not supported in
> > the CMake ports (GTK and WPE currently). It uses os_log() which is only
> > supported on Mac. Check https://developer.apple.com/documentation/os/os_log
> > and bug 160969 that introduced it
> 
> We could define RELEASE_LOG macros to use "normal" logging. Though for me
> personally it would be really nice to see ltt-ng's tracelog() support
> built-in :)

That would be a different thing that I want to do here.
Please open a new bug for that if you wish.
Comment 11 Carlos Alberto Lopez Perez 2018-01-17 09:33:30 PST
(In reply to Carlos Alberto Lopez Perez from comment #10)
> (In reply to Konstantin Tokarev from comment #7)
> > (In reply to Carlos Alberto Lopez Perez from comment #4)
> > > RELEASE_LOG_DISABLED is another complete different thing not supported in
> > > the CMake ports (GTK and WPE currently). It uses os_log() which is only
> > > supported on Mac. Check https://developer.apple.com/documentation/os/os_log
> > > and bug 160969 that introduced it
> > 
> > We could define RELEASE_LOG macros to use "normal" logging. Though for me
> > personally it would be really nice to see ltt-ng's tracelog() support
> > built-in :)
> 
> That would be a different thing that I want to do here.
> Please open a new bug for that if you wish.

I mean "That would be a different thing than what I want to do here."
Comment 12 Carlos Alberto Lopez Perez 2018-01-17 09:37:40 PST
(In reply to Carlos Alberto Lopez Perez from comment #9)
> (In reply to Michael Catanzaro from comment #5)
> > Comment on attachment 331491 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=331491&action=review
> > 
> > > Source/cmake/OptionsCommon.cmake:99
> > > +if (DEVELOPER_MODE)
> > > +    # Explicit enable logging support (ensures its also enabled on release development builds).
> > > +    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLOG_DISABLED=0")
> > > +endif ()
> > 
> > Can you find a better way to do this? What is setting LOG_DISABLED in the
> > first place?
> 
> I don't think there is a better way to do this.
> On debug mode DLOG_DISABLED=0 gets set on the header because cmake defines
> -DNDEBUG=1
> 
> Can you please remove the r-?

Well, it is possible to set it on wtf/Assertions.h if DEVELOPER_MODE is set. I can do that if you prefer.
Comment 13 Carlos Alberto Lopez Perez 2018-01-17 10:48:04 PST
Created attachment 331516 [details]
Patch

Patch v2, set logging on wtf/Assertions.h
Comment 14 Carlos Alberto Lopez Perez 2018-01-17 11:31:14 PST
Comment on attachment 331516 [details]
Patch

The are more than LOG_DISABLED that should be set to 0.
Will upload new patch
Comment 15 Michael Catanzaro 2018-01-17 12:02:26 PST
(In reply to Carlos Alberto Lopez Perez from comment #12)
> Well, it is possible to set it on wtf/Assertions.h if DEVELOPER_MODE is set.
> I can do that if you prefer.

That sounds better!

(In reply to Konstantin Tokarev from comment #8)
> Are you really ready to fix all WebCore assertion as they pop up when sites
> change their content?

Nope, but this is a proposal for DEVELOPER_MODE. Problem is, some of our developers like to use release builds, and don't notice when their code is broken because they aren't running assertions. Anyway, this a topic for another bug, another day....
Comment 16 Carlos Alberto Lopez Perez 2018-01-17 12:51:36 PST
Created attachment 331534 [details]
Patch

Patch v3, enable also error and fatal logs on developer builds
Comment 17 Carlos Alberto Lopez Perez 2018-01-17 12:57:11 PST
Comment on attachment 331534 [details]
Patch

Will try to do this in Assertions.h rather than in the cmake file.
Comment 18 Konstantin Tokarev 2018-01-17 13:30:42 PST
(In reply to Michael Catanzaro from comment #15)
> Problem is, some of our developers like to use release builds, and don't notice when their code is broken because they aren't running assertions.

Same problem here. I think the only working solution (if WebCore's assert rate didn't decrease significantly between my branch and trunk) is having non-fatal assertions, just print message + backtrace and proceed.
Comment 19 Konstantin Tokarev 2018-01-17 13:35:50 PST
Also, I can name yet another problem: JSC in general and Inspector in particular are too slow in debug, so everyone tries to avoid debug builds. I didn't research it yet, but I guess there may be unneeded assertions on the hot paths(which could be removed or put under special ifdef guards), and there may be hot paths which badly lack compiler optimizations (maybe we need to build JSC with enabled optimization in all build types, in old times Qt port was using this trick)
Comment 20 Carlos Alberto Lopez Perez 2018-01-17 13:43:38 PST
(In reply to Konstantin Tokarev from comment #19)
> Also, I can name yet another problem: JSC in general and Inspector in
> particular are too slow in debug, so everyone tries to avoid debug builds. I
> didn't research it yet, but I guess there may be unneeded assertions on the
> hot paths(which could be removed or put under special ifdef guards), and
> there may be hot paths which badly lack compiler optimizations (maybe we
> need to build JSC with enabled optimization in all build types, in old times
> Qt port was using this trick)

That is because Debug gets compiled with -O0. WebKit/JSC is painful slow without compiler optimizations.