Closed
Bug 1360497
Opened 7 years ago
Closed 7 years ago
Add -Zdebug-macros to RUSTFLAGS
Categories
(Firefox Build System :: General, enhancement)
Firefox Build System
General
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: hsivonen, Unassigned)
References
Details
Attachments
(1 file)
By default, rustc annotates lines expanded from a macro with the location of the macro invocation rather than the location of the line in the macro definition. In case of e.g. encoding_rs, this results in pretty useless panic stacks. To make panic stacks useful on try and in the crash reporter, we should add -Zdebug-macros to RUSTFLAGS to override the default behavior and to get stacks with usefully actionable location info. Additionally, accoding to https://github.com/rust-lang/rust/issues/39153#issuecomment-297685269 , it seems that this would be useful for correct profiling attribution, too.
Comment hidden (mozreview-request) |
Reporter | ||
Comment 2•7 years ago
|
||
Hmm. The patch doesn't appear to have the expected effect: https://treeherder.mozilla.org/logviewer.html#?job_id=95143210&repo=try&lineNumber=2243 (No lines from macros.rs involved.)
Reporter | ||
Comment 3•7 years ago
|
||
(In reply to Henri Sivonen (:hsivonen) from comment #2) > Hmm. The patch doesn't appear to have the expected effect: Because I misread the "if" nesting in a hurry. Sigh.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Reporter | ||
Comment 6•7 years ago
|
||
Not what I hoped for in this case, but at least the flag seems to take effect with the current patch: https://treeherder.mozilla.org/logviewer.html#?job_id=95476817&repo=try&lineNumber=4658
Reporter | ||
Updated•7 years ago
|
Attachment #8862777 -
Flags: review?(ted)
Comment 7•7 years ago
|
||
It sounds like we have to make a choice between two suboptimal situations: a) The current situation, where panic stacks/profiling are not very useful for code involving macros. b) -Zdebug-macros, where anyone debugging Rust code will wind up stepping through macros from the standard library.
Comment 8•7 years ago
|
||
Comment on attachment 8862777 [details] Bug 1360497 - Use line numbers from macro definition rather than macro invocation for code expanded from macros. I'm going to let froynj make the call here.
Attachment #8862777 -
Flags: review?(ted) → review?(nfroyd)
Reporter | ||
Comment 9•7 years ago
|
||
(In reply to Ted Mielczarek [:ted.mielczarek] from comment #7) > b) -Zdebug-macros, where anyone debugging Rust code will wind up stepping > through macros from the standard library. Do we have a lot of code in Firefox where this is a problem? Does gdb's "skip file" not correctly skip over lines from a standard-library macro expansion if you tell it to skip over the file that defines the macro?
Reporter | ||
Comment 10•7 years ago
|
||
(In reply to Henri Sivonen (:hsivonen) from comment #9) > (In reply to Ted Mielczarek [:ted.mielczarek] from comment #7) > > b) -Zdebug-macros, where anyone debugging Rust code will wind up stepping > > through macros from the standard library. > > Do we have a lot of code in Firefox where this is a problem? Does gdb's > "skip file" not correctly skip over lines from a standard-library macro > expansion if you tell it to skip over the file that defines the macro? FWIW, I think losing the line of assert macro invocation is a more significant adverse outcome of the proposed change than the impact on stepping over write!() and such when debugging. Ideally, we'd get the macro invocation line for assert macros and the macro definition line for other macros and would use gdb skipping filters to decide at debug time what to skip when stepping.
Comment 11•7 years ago
|
||
mozreview-review |
Comment on attachment 8862777 [details] Bug 1360497 - Use line numbers from macro definition rather than macro invocation for code expanded from macros. https://reviewboard.mozilla.org/r/134660/#review145150 Sorry for taking so long to respond to this. There is just no good solution here, and I'm not comfortable enabling something that we'll have to throw away shortly before we upgrade Rust, as it sounds like they're disabling `-Z` options in stable. So we'd have to start with changing the command-line flags to provide a stable interface, and then add the appropriate flags (probably only enabled for `--enable-release` builds). Permitting people to pass in their own `RUSTFLAGS` would be a reasonable change on its own, though, and then people who wanted `-Z debug-macros` or what have you could get the behavior they like locally.
Attachment #8862777 -
Flags: review?(nfroyd) → review-
Reporter | ||
Comment 12•7 years ago
|
||
Marking WONTFIX per comment 11. I started a discussion about a better alternative on the Rust Internals forum but the discussion didn't get much interest: https://internals.rust-lang.org/t/stack-trace-friendly-debug-info-for-macros/5370
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Updated•6 years ago
|
Product: Core → Firefox Build System
You need to log in
before you can comment on or make changes to this bug.
Description
•