C++ Logo

sg15

Advanced search

Re: [SG15] breakpoint and is_debugger_present proposals.

From: René Ferdinand Rivera Morell <grafikrobot_at_[hidden]>
Date: Sat, 15 Jan 2022 20:26:27 -0600
Thanks Timur.

On Wed, Jan 5, 2022 at 5:37 AM Timur Doumler via SG15 <sg15_at_[hidden]>
wrote:

> I am strongly in favour of this feature. It has been implemented
> cross-platform in the JUCE framework
> <https://github.com/juce-framework/JUCE>, where it has proven to be very
> useful in practice. It is used in JUCE’s jassert macro, which triggers a
> breakpoint whenever an assertion fails, if (and only if) we are running a
> debug build and a debugger is attached:
>
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/system/juce_PlatformDefs.h#L152
>
> This has always worked well for me on all the relevant platforms.
>
> juce_isRunningUnderDebugger() (equivalent of std::is_debugger_present) is
> implemented as follows:
> Android:
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/native/juce_android_Threads.cpp#L378
>

When I implemented the UE4 Android version of that, 7 years ago, I ended up
calling the Java methods (from C++) as the Linux proc/self/status wasn't an
option :-(


> Linux:
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/native/juce_linux_SystemStats.cpp#L348
> macOS:
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/native/juce_mac_Threads.mm#L74
> Windows:
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/native/juce_win32_Threads.cpp#L230
>
> and JUCE_BREAK_IN_DEBUGGER (equivalent of std::breakpoint) is implemented
> as follows:
> https://github.com/juce-framework/JUCE/blob/ddaa09110392a4419fecbb6d3022bede89b7e841/modules/juce_core/system/juce_PlatformDefs.h#L62
>
> I hope this is useful.
>

It's very, very useful!

-- 
-- René Ferdinand Rivera Morell
-- Don't Assume Anything  -- No Supone Nada
-- Robot Dreams - http://robot-dreams.net

Received on 2022-01-16 02:26:40