Skip to content

'cabal repl' with stack traces #7674

Open
@emlautarom1

Description

@emlautarom1

I've been looking around for a set of flags/configurations that would allow me to load my project into GHCi and have access to stack traces. So far, I found this blog post that explains how to access stack traces from plain GHCi (not from cabal repl). I also found this in the official docs - which is practically a summary of the blog post.

What I've tried so far with no success:

  • Add -fexternal-interpreter -prof to the ghc-options section in my .cabal file
  • Run cabal repl --ghc-options="-fexternal-interpreter -prof". I got a warning from GHCi, but no stack traces.
  • Run cabal repl -p. This required installing the ghc-prof library (I'm using Fedora).
  • Run cabal exec ghci -- -fexternal-interpreter -prof. I got some errors related to missing files in the new-dist folder. Then, I recompiled with cabal build -p.

My project has several targets (a lib, a test suite and several executables). What I want is to load the library (the default when running cabal repl) and use Debug.traceStack. I do not care about getting stack traces from third party dependencies, I just care about what my code is doing.

Right now I'm using HasCallStack as a workaround, but the traces are extremely short (a single function) and it's very inconvenient to add the constraint on every function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions