Community
Participate
Working Groups
Created attachment 273016 [details] Adds the sysvar template + externalized description As described at https://advancedweb.hu/2017/11/28/print-debugging/, we should have a template to support print debugging. I changed the name of the template from "sysoutv" (as proposed by the link) to "sysvar", as it feels more in line with existing "sysout" and "systrace" templates. The template's description reads print variable name and value to standard out The template's contents are System.out.println("${var} = " + ${var});${cursor}
GitHub Pull Request 7 created by [enikao] https://github.com/eclipse/eclipse.jdt.ui/pull/7
IMHO, even cooler would be a way to teach users the use of print points[1] instead of cluttering your code with sysouts. [1] http://blog.deepakazad.com/2010/06/print-points-debugging-by-writing-to.html
Print points are mentioned in the next installment[1] of the same series of articles, including extensive lists of pros and cons. I think both of them have their merits. [1] https://advancedweb.hu/2018/02/06/debug/
(In reply to Niko Stotz from comment #3) > Print points are mentioned in the next installment[1] of the same series of > articles, including extensive lists of pros and cons. I think both of them > have their merits. > > [1] https://advancedweb.hu/2018/02/06/debug/ From a quick scan the Pros and Cons refer to debugging in general, not to print points in particular. Am I missing anything?
Print points are now available as tracepoints in Eclipse: https://www.eclipse.org/eclipse/news/4.7/M5/#JDT. Adding Sarika in cc for her views on the proposed template.
(In reply to Noopur Gupta from comment #5) > Print points are now available as tracepoints in Eclipse: > https://www.eclipse.org/eclipse/news/4.7/M5/#JDT. > > Adding Sarika in cc for her views on the proposed template. I think of print points slightly differently (at least in this context). They would also print the name and value of a variable. In a sense: systrace template <--> tracepoint breakpoint sysvar template <--> printpoint breakpoint I'll look into another patch adding printpoints.
Tracepoints overcomes the biggest con of print-points - that is cluttering of the code. It will be better to enhance Tracepoints for variable printing - if a variable is selected in editor, it can add the variable print. Just thinking aloud.
I agree printpoints, in general, are to be preferred over println statements. However, there are quite common scenarios where printpoints don't help that much, e.g. * Execution environment cannot be debugged (remote server etc.) * Execution is very sensitive to performance overhead of debug mode