-
-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor expressionsem using debug condition #12636
Conversation
Thanks for your pull request and interest in making D better, @12345swordy! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#12636" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise looks good
Added suggested comment
I do not understand what the purpose of this change is. I spent a lot of time debugging expressionsem, and I never need to turn them on globally for dmd. If I did, it would absolutely bury me in irrelevant noise. The idea is to turn them on in a focused, very targeted manner. There's no reasonable way to generalize this. The I'll also tend to turn on LOG-like variables (as enums) inside a function to turn on/off only the logging for that function. I don't see what value a log audit adds. |
@WalterBright You are the most knowledgeable person in terms of dmd internals, therefore whenever you want to debug something you know exactly where to look. People that are starting to contribute on the compiler or even experienced contributors sometimes find it hard to understand the chain of semantic analysis calls. For them, having a log file with tons of information is extremely helpful. I, personally, could have used something like this in the past. Also, this does not affect in any way your strategy of targeted printing, you can easily comment the debug statement. One major advantage of the log system is that it could output a file that could be used as an input to a visual representation program that could create an image with the call chain. |
Turn everything on, and the log file will be an utterly hopeless mass of useless data. Printing the call chain is indeed highly useful, and the debugger does that nicely, without all the mess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a better rationale
You can just as well do: //debug(LOGSEMANTIC)
{
printf(...);
} |
|
I recently tried to figure out escape.d to fix some -dip1000 bugs, so I turned logging on. To do that, you have to do a mix of:
Afterwards, you go through your git diff to undo all that. I don't think it's handy currently. On top of that, enums are often printed as numbers: printf("storage class = x%llx\n", v.storage_class); To read that out, you need to e.g. look up that
I agree, but a dedicated logging function can retrieve I know this PR alone does not yet show clear benefits, but I hope at least you're not opposed to dlang/project-ideas#79 as a whole. Maybe @12345swordy can outline the bigger picture a bit more, since this PR alone indeed lacks rationale. |
Having a skim over the project description, this goal seems misplaced.
It would be better to just leave the existing printfs alone. |
No, we need to replace the printfs, as the failing test suit relies on the console output to indicated that it passes or not. If you are running the failing test on your local machine and you want to know why the failing test are not passing than you do not want printf effecting it. |
Done. |
The printfs are not causing any harm to those who make use of them. Meanwhile a logging/audit system can be added independently alongside them. |
Sure thing. However we shouldn't allow any comment code in dmd, including printf. |
@WalterBright Can you please take another look at this? |
@RazvanN7 I add further justification to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rationale does not address the critique of the change. The addition of a log/audit does not equate to changing the existing code used for occasional debugging. Particularly if the intermediate state has more drawbacks than the original.
Yes it does. I said it right here:
It does if you want to log audit to
This can not be achieved with the current system.
You can always do this //debug(LOGSEMANTIC)
{
printf(...);
} or this
This isn't any different than what is currently set up. |
Let me provide wider context of why I am pursuing the audit log: |
This statement from @WalterBright.
I agree! This should be reconsidered so that a better approach is taken. |
What alternatives do you propose here then? Using debug condition is intuitive and makes sense as you should be developing dmd in debug mode, not in release mode. The current system is unacceptable as it requires you to modify the code when you want information from dmd while debugging and you have to unmodified the code when you create a commit, so that it won't appear in the release build. Debug condition for all intents and purposes, allows you to "Break the rules", which is a good idea when it comes to logging. You can't break the rules, when using static if, as far as I know. Any alternative that involves the programmer modifying the code to activate/modifying the logging system and not by a compiler flags is not a viable nor feasible alternative here. |
I've been doing it for 40 years. |
The logging is for other people who are not familiar with dmd intervals as you are here. I wouldn't be doing this if the debug integration with VS isn't very subpar compare to other languages. |
I didn't realize this had anything to do with VS. Can you explain further? |
I already did here |
Closing this branch as we don't see eye to eye on this. |
First step of implementing a log audit for dmd.
dlang/project-ideas#79
Rational: You should not have to modify the code in order to enable logging to see what is going on behind the scene when working in dmd. The logging system needs to be triggered by a compiler command when compiling dmd. The current logging code itself is inconstant as some of them rely on using
version(none)
while others are just marked as//printf
. Using the debug condition allows this to be triggered by a compiler command. Which then can be documented and easy to use.The first step is to wrap the printf statements in a debug condition statement. Then replace the printf statements with the log function that allows you to select the type of information that you would like to see by using the compiler flags that are created by the debug condition.
cc @RazvanN7