D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3321 - debug flags
Summary: debug flags
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Andrej Mitrovic
URL:
Keywords: pull, spec
: 3721 (view as issue list)
Depends on:
Blocks:
 
Reported: 2009-09-16 20:12 UTC by Ellery Newcomer
Modified: 2013-02-06 17:53 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ellery Newcomer 2009-09-16 20:12:35 UTC
test.d:

debug pragma(msg,"hi!");
void main() {}


$ dmd2 test
(no output)

$ dmd2 -debug test
hi!

$ dmd2 -debug=1 test
hi!

$ dmd2 -debug=ellery test
(no output)                      WHAT???????
Comment 1 Ellery Newcomer 2009-09-16 20:23:48 UTC
a quick peek in the source shows that debug <=> debug(1)

is this sane behavior?
Comment 2 Ary Borenszweig 2009-09-17 04:18:53 UTC
Yes, that's normal behaviour. And:

$ dmd2 -debug=ellery test

will print "hi!" if the code is:

debug(ellery) pragma(msg,"hi!");
void main() {}

I won't close this as invalid because the specification doesn't say exactly this. It says:

---
The debug condition is satisfied when the -debug switch is thrown on the compiler.

The debug ( Integer ) condition is satisfied when the debug level is >= Integer.

The debug ( Identifier ) condition is satisfied when the debug identifier matches Identifier. 
---

It should say:

The debug condition is satisfied when the -debug switch is thrown on the compiler or when a debug level >= 1 is indicated.

(or something like that)
Comment 3 Ellery Newcomer 2009-09-17 07:44:38 UTC
(In reply to comment #2)
> Yes, that's normal behaviour.

According to whom? The C preprocessor?

When I read the spec, I came away with the impression that debug should work like so:

debug { stuff } should get compiled if the compiler is given -debug or -debug={something}. Basically, I see it as a boolean. Are we in a debug compile?

debug(number) { stuff } should get compiled if the compiler is given -debug=n, where n >= number (and there's nothing that says debug(0) { stuff } will always get compiled)

wait, I'm seeing a pattern here 1 -> true, 0 -> false. That sorta makes sense.

debug(id) { stuff } should get compiled if the compiler is given -debug=id


Yeah, spec needs to be more precise. I would like to see -debug=id => debug_level=1, though.
Comment 4 yebblies 2011-06-12 22:11:46 UTC
*** Issue 3721 has been marked as a duplicate of this issue. ***