Issue 23423 - Feature Request: version(D_DebugInfo)
Summary: Feature Request: version(D_DebugInfo)
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-17 10:59 UTC by ponce
Modified: 2022-12-17 10:31 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ponce 2022-10-17 10:59:51 UTC
Hello. I'd like to have:

    version (D_DebugInfo)
    {}
    else
    {
        version = enableFeatureThatIsAnnoyingWhenDebugging;
    }

Is there a way to know if debug info is being emitted when compiling?
"debug" is not cutting it because sometimes you really need to debug with or without -debug, and with or without -O. 
I would want -g.
Comment 1 Dennis 2022-11-11 12:07:40 UTC
There's now precedence for version identifiers based on codegen flags with `D_Optimized`: https://github.com/dlang/dmd/pull/14245

Still, I would like to have solid rationale before adding another.

What kind of feature is annoying when debugging? 
Also, can't you pass `-g -version=disableFeatureThatIsAnnoyingWhenDebugging`?
Comment 2 ponce 2022-11-11 13:03:17 UTC
Dplug software has a mouse hook that is active to allow using the mouse wheel when dragging outside of the window. Others OSes can do that, but Windows needs a mouse hook.

When debugging, this is extra slow, but in normal times it is invisible. Hence, for practicality it's better to disable this.

- D_Optimized is obviously not the same as D_Optimized, it's frequent to want to debug optimized builds


- I don't see why -g would one of the only flags you can detect. -g is the closest flag to "I will debug this interactively".

> Also, can't you pass `-g -version=disableFeatureThatIsAnnoyingWhenDebugging`?

No. That doesn't solve the problem, as we use dub, and version identifiers are set by configurations not build types.
Comment 3 ponce 2022-11-11 13:04:01 UTC
> D_Optimized is obviously not the same as D_Optimized

Corerection not the same as D_DebugInfo*
Comment 4 ponce 2022-11-11 13:04:51 UTC
> you can detect

you couldn't* detect
Comment 5 apham 2022-11-11 14:09:23 UTC
Why D don't create corresponding versions for all simple flags? 

Some sample flags
DMD -g -debug -inline

will have following defined versions, Dflag can be shorten to Df
Dflag_g  Dflag_debug Dflag_inline

so usage is
version(Dflag_g)
version(Dflag_debug)
version(Dflag_inline)
Comment 6 ponce 2022-11-13 01:08:24 UTC
That's not what this bug is about, it's just about -g