
Hi, I would like to enable stack traces at launch time and run program without HasCallStack overhead by default. I've got an idea to use GHC plugin which would duplicate all functions in modules with specified prefix. Duplicated functions should get disambiguating prefix (e.g. "debug") and HasCallStack constraint. Bodies of prefixed functions should be rewritten to use prefixed functions from matching modules (should be easy to do - hook just after renaming GHC phase when all names are fully qualified?). This way main function could choose "runLib" or "debugRunLib". Did anybody make something similar? -- Best regards, Daniil Iaitskov

Have you tried the -xc flag yet? If you do a profiling build and then run your program with +RTS -xc it will give a stack trace on exceptions. (I think your idea still has some content but ^ is easier because it already exists!) On 12/12/21 2:01 PM, Daneel Yaitskov wrote:
Hi,
I would like to enable stack traces at launch time and run program without HasCallStack overhead by default. I've got an idea to use GHC plugin which would duplicate all functions in modules with specified prefix. Duplicated functions should get disambiguating prefix (e.g. "debug") and HasCallStack constraint. Bodies of prefixed functions should be rewritten to use prefixed functions from matching modules (should be easy to do - hook just after renaming GHC phase when all names are fully qualified?).
This way main function could choose "runLib" or "debugRunLib".
Did anybody make something similar?
--
Best regards, Daniil Iaitskov
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

On Sun, Dec 12, 2021 at 3:54 PM Vanessa McHale
Have you tried the -xc flag yet?
Thanks for -xc option. Does program run without CPU overhead when -xc is off? I see that object file must be bigger, but CPU/RAM requirement is not clear. -xc has an issue https://gitlab.haskell.org/ghc/ghc/-/issues/20536 I encountered recently. Some libraries (e.g. directory) use exceptions for normal control flow. So lots of stack traces could be produced. There is no control over what exception stack trace should be displayed. The app is based on a Haskell interpreter to run user scripts. It would be hard to understand such output for users.
If you do a profiling build and then run your program with +RTS -xc it will
give a stack trace on exceptions.
(I think your idea still has some content but ^ is easier because it already exists!) On 12/12/21 2:01 PM, Daneel Yaitskov wrote:
Hi,
I would like to enable stack traces at launch time and run program without HasCallStack overhead by default. I've got an idea to use GHC plugin which would duplicate all functions in modules with specified prefix. Duplicated functions should get disambiguating prefix (e.g. "debug") and HasCallStack constraint. Bodies of prefixed functions should be rewritten to use prefixed functions from matching modules (should be easy to do - hook just after renaming GHC phase when all names are fully qualified?).
This way main function could choose "runLib" or "debugRunLib".
Did anybody make something similar?
--
Best regards, Daniil Iaitskov
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to:http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- Best regards, Daniil Iaitskov
participants (2)
-
Daneel Yaitskov
-
Vanessa McHale