Skip to content

RFC pragma(breakpoint) - #21758

Draft
benjones wants to merge 9 commits into
dlang:masterfrom
benjones:pragmaBreakpoint
Draft

benjones wants to merge 9 commits into
dlang:masterfrom
benjones:pragmaBreakpoint

Conversation

@benjones

@benjones benjones commented Aug 22, 2025 •

Copy link
Copy Markdown
Contributor

Here's a first pass at pragma(breakpoint) as I described in my dconf talk. So far, it's basically pragma(backtrace) with no interactive features. Curious what people think about this (is it useful? is it the right information?)

Here's the output from the new test:

Pragma Breakpoint: static else, before expanding the dependent template
Starting backtrace
compiler/test/compilable/pragmaBreakpoint.d(8): scope: T
compiler/test/compilable/pragmaBreakpoint.d(2): scope: T!3LU
compiler/test/compilable/pragmaBreakpoint.d(17): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/compilable/pragmaBreakpoint.d: scope: __anonymous
Pragma Breakpoint: static else, before expanding the dependent template
Starting backtrace
compiler/test/compilable/pragmaBreakpoint.d(8): scope: T
compiler/test/compilable/pragmaBreakpoint.d(2): scope: T!2LU
compiler/test/compilable/pragmaBreakpoint.d(9): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/compilable/pragmaBreakpoint.d: scope: __anonymous
Pragma Breakpoint: static else, before expanding the dependent template
Starting backtrace
compiler/test/compilable/pragmaBreakpoint.d(8): scope: T
compiler/test/compilable/pragmaBreakpoint.d(2): scope: T!1LU
compiler/test/compilable/pragmaBreakpoint.d(9): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/compilable/pragmaBreakpoint.d: scope: __anonymous
Pragma Breakpoint: done T!0LU
Starting backtrace
compiler/test/compilable/pragmaBreakpoint.d(6): scope: T
compiler/test/compilable/pragmaBreakpoint.d(2): scope: T!0LU
compiler/test/compilable/pragmaBreakpoint.d(9): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/compilable/pragmaBreakpoint.d: scope: __anonymous
Pragma Breakpoint: main
Starting backtrace
compiler/test/compilable/pragmaBreakpoint.d(21): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d(15): scope: __anonymous
compiler/test/compilable/pragmaBreakpoint.d(15): scope: pragmaBreakpoint
compiler/test/compilable/pragmaBreakpoint.d: scope: __anonymous

@dlang-bot

Copy link
Copy Markdown

Thanks for your pull request and interest in making D better, @benjones! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21758"

@benjones
benjones marked this pull request as draft August 22, 2025 08:46
@benjones

Copy link
Copy Markdown
Contributor Author

more (potential) discussion here: https://forum.dlang.org/post/bfznqduaojatgfxunygl@forum.dlang.org

@thewilsonator thewilsonator added Review:Needs Changelog A changelog entry needs to be added to /changelog Review:Needs Spec Change A change updating the language specification needs to be submitted as part of this PR labels Aug 22, 2025
@benjones
benjones force-pushed the pragmaBreakpoint branch 2 times, most recently from 7c31bc2 to 26e1f78 Compare August 22, 2025 10:17
@benjones

benjones commented Oct 7, 2025

Copy link
Copy Markdown
Contributor Author

I've added the outline of making this interactive:

./generated/osx/release/64/dmd compiler/test/runnable/pragmaBreakpoint.d
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) bt
Backtrace
compiler/test/runnable/pragmaBreakpoint.d(45): scope: T
compiler/test/runnable/pragmaBreakpoint.d(39): scope: T!3LU
compiler/test/runnable/pragmaBreakpoint.d(54): scope: __anonymous
compiler/test/runnable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/runnable/pragmaBreakpoint.d: scope: __anonymous
(ctdb) c
continuing compilation
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) c
continuing compilation
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) c
continuing compilation
Pragma Breakpoint: done T!0LU
(ctdb) c
continuing compilation
Pragma Breakpoint: main
(ctdb) c
continuing compilation

I assume there's a way to add this to the test above to make it run non-interactively?

/Users/ben/projects/dlang/dmd/dmd $ cat > pragmaMessageInputs.txt <<- EOM
heredocd> bt
heredocd> c
heredocd> c
heredocd> c
heredocd> c
heredocd> c
heredocd> EOM
/Users/ben/projects/dlang/dmd/dmd $ ./generated/osx/release/64/dmd compiler/test/runnable/pragmaBreakpoint.d < pragmaMessageInputs.txt
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) Backtrace
compiler/test/runnable/pragmaBreakpoint.d(45): scope: T
compiler/test/runnable/pragmaBreakpoint.d(39): scope: T!3LU
compiler/test/runnable/pragmaBreakpoint.d(54): scope: __anonymous
compiler/test/runnable/pragmaBreakpoint.d: scope: pragmaBreakpoint
compiler/test/runnable/pragmaBreakpoint.d: scope: __anonymous
(ctdb) continuing compilation
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) continuing compilation
Pragma Breakpoint: static else, before expanding the dependent template
(ctdb) continuing compilation
Pragma Breakpoint: done T!0LU
(ctdb) continuing compilation
Pragma Breakpoint: main
(ctdb) continuing compilation

Thoughts/feedback? Next thing to add will be something to print symbols in the various scopes of the backtrace.

@benjones
benjones force-pushed the pragmaBreakpoint branch 2 times, most recently from 223404d to 668aec8 Compare October 23, 2026 21:08
@benjones

Copy link
Copy Markdown
Contributor Author

Finally had some time to come back to this. Any feedback on the functionality? There's definitely some improvements to be made to the implementation, but I'll hold off on them until I'm confident that this is headed in the right direction. I can't tell if my test is causing the CI to hang, or if it's normal issues (looks to be hanging on ... fail_compilation/cast_qual.d -verrors=simple -verrors=0 -preview=dip1000 -de -fPIC () on the Ubuntu runners which makes me think it's not an issue with my new dshell test, but I can't use the runner locally since I'm on an ARM mac...)

@benjones
benjones force-pushed the pragmaBreakpoint branch 8 times, most recently from 12b890e to 3019896 Compare October 24, 2026 20:03
Comment thread compiler/src/dmd/common/stringutil.d Outdated
@benjones
benjones force-pushed the pragmaBreakpoint branch 8 times, most recently from bb15867 to 64dc4df Compare October 27, 2026 16:43
@github-actions

Copy link
Copy Markdown

DMD perf check

Metric Base PR Δ
compile dmd itself (wall) 10.6 s 9.7 s -8.49%
All measurements
Metric Base PR Δ
compile hello.d (instr) 203.5 M 203.5 M +0.008%
compile hello.d -O -release (instr) 221.1 M 221.1 M +0.015%
compile Phobos (instr) 4,709.6 M 4,710.1 M +0.010%
compile Phobos codegen (instr) 1,421.6 M 1,421.8 M +0.013%
compile vibe.d (instr) 13,564.2 M 13,569.9 M +0.042%
compile ctRegex tests (instr) 29,185.5 M 29,188.9 M +0.012%
dmd binary size (stripped) 8.18 MB 8.18 MB 0.00%
hello binary size (stripped) 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 44.39 MB 44.30 MB -0.19%
peak RSS (compile Phobos) 610.6 MB 611.3 MB +0.11%
peak RSS (compile vibe.d) 1879 MB 1879 MB -0.02%
peak RSS (compile ctRegex tests) 2040 MB 2042 MB +0.07%
page faults (compile hello.d) 8,732 8,729 -0.03%
page faults (compile Phobos) 152,347 151,986 -0.24%
page faults (compile vibe.d) 470,098 470,034 -0.01%
page faults (compile ctRegex tests) 497,815 498,202 +0.08%
compile dmd itself (wall) 10.6 s 9.7 s -8.49%
compile ctRegex tests (wall) 3,263 ms 3,181 ms -2.53%
compile hello.d (wall) 52.8 ms 71.8 ms +35.91%
compile Phobos (wall) 1,188 ms 1,181 ms -0.51%

798ca1e vs merge-base 21cf5b1 · about these metrics · historical dashboard

.map!(l => l.replace("\\", "/")) //paths are different on different platforms. TODO, use module name instead?
.filter!(l => l.length > 0)
.join("\n");
assert(output == expectedOutput, "actual output:\n" ~ output ~ "\nexpected output:\n" ~ expectedOutput);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ERROR: Found the following residual temporary files.
ERROR: Temporary files should be stored in `test_results` or explicitly removed.
?? compiler/test/pragmabreakpoint

while(true)
{
auto result = tryWait(proc);
if(result.terminated){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces between if and opening (

enforce(result.status == 0);
break;
}
if(MonoTime.currTime > deadline){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

inputPipe.writeEnd.write("bt\nm 3\nc\nc\nc\nbt\nm 1\nc\nc\nc\nc\n"); //2 extra "continue" + newlines should be ignored
inputPipe.writeEnd.flush();
const deadline = MonoTime.currTime + 5.seconds;
while(true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@thewilsonator

Copy link
Copy Markdown
Contributor

This looks good to me, you might want to bring this up at the Foundation monthly.

@benjones

Copy link
Copy Markdown
Contributor Author

This looks good to me, you might want to bring this up at the Foundation monthly.

I'll fix the issues you brought up later today, hopefully. When is the next meeting? I've never joined one before (my email is ben.james.jones@gmail.com if you want to take this out of the PR comments)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Needs Changelog A changelog entry needs to be added to /changelog Review:Needs Spec Change A change updating the language specification needs to be submitted as part of this PR Severity:Enhancement stalled

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants