Lexical call site string
|Reported by:||paul@…||Owned by:|
|Keywords:||Cc:||claus.reinke@…, ndmitchell@…, id@…, pho@…, miffoljud@…|
|Type of failure:||None/Unknown||Test Case:||N/A|
|Related Tickets:||Differential Rev(s):|
A function that returns the lexical call site of the current function when an exception occurs.
I'm thinking primarily of "head ", but the same principle would apply to other functions. A dynamic traceback is not necessarily possible in a lazy language, but when "head" gets called on an empty list there must be somewhere in the program that actually said "head", even if it was not evaluated at the time or included in a closure or something. That way when I get a "head: empty list" I don't need to grep my program for "head" calls: I know where head was called from and can start looking there.
- If I just have a function "foo = head" then it will report that the caller was "foo".
- If I have a function "bar x y = ..." and subsequntly say "baz x = bar (x * 2)" then an exception in "bar" will report the caller as "baz".
I know there is a -x profiler option to get a sort of dynamic traceback, but I find it frequently just tells me the error is in "CAF.List", which isn't very informative.
I'm guessing at a difficulty of 1 week as I don't know the GHC internals. I'm guessing that the call site is going to have to be a hidden parameter passed in to each function call, or alternatively hard-coded when a function is in-lined.
Change History (19)
comment:11 Changed 7 years ago by Isaac Dupree
- Cc claus.reinke@… ndmitchell@… id@… added; claus.reinke@… removed
comment:13 Changed 7 years ago by simonmar
- Operating System changed from Unknown to Unknown/Multiple