# Showing function calls (like in stacktrace)

**URL:** <https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307>\
**Category:** General Usage\
**Created:** [August 9, 2017, 4:08pm UTC](https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307 "2017-08-09T16:08:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [August 9, 2017, 4:08pm UTC](https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307/1 "2017-08-09T16:08:12Z")

</div>

Is there a way to show the functions called inside a function like in the stacktrace of error messages, even if the function returns successfully?

In other words, I would like to see something like [1]–[6] in the following error message, from the start to the end of a function call:

```julia
julia> broadcast(+, [1 2; 3 4], [1 2; 3 4; 5 6])
ERROR: DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
 [1] _bcs1(::Base.OneTo{Int64}, ::Base.OneTo{Int64}) at ./broadcast.jl:70
 [2] _bcs at ./broadcast.jl:63 [inlined]
 [3] broadcast_shape at ./broadcast.jl:57 [inlined] (repeats 2 times)
 [4] broadcast_indices at ./broadcast.jl:53 [inlined]
 [5] broadcast_c at ./broadcast.jl:311 [inlined]
 [6] broadcast(::Function, ::Array{Int64,2}, ::Array{Int64,2}) at ./broadcast.jl:434

```

I need this capability to debug semantic errors by showing all the functions visited and examine what went wrong. Currently I’m achieving this by successively calling `which`.

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [August 9, 2017, 4:19pm UTC](https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307/2 "2017-08-09T16:19:30Z")

</div>

Have you heard of [Jupyter Notebook Viewer](http://nbviewer.jupyter.org/github/cstjean/TraceCalls.jl/blob/master/README.ipynb)?

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [August 9, 2017, 5:45pm UTC](https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307/3 "2017-08-09T17:45:11Z")

</div>

TraceCalls isn’t super good at tracing Base code at the moment. You have to specify the functions manually, and Base tends to use a lot of `eval`, `@generated` and `@inline`, all of which aren’t traceable yet. But stay tuned!

```julia
BB = Base.Broadcast
broadcast_funs = (BB.broadcast, BB.broadcast_c, BB.broadcast_indices, BB.broadcast_shape, BB._bcs, BB._bcs1)
@trace broadcast_funs broadcast(+, [1 2; 3 4], [1 2; 3 4])

```

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [August 11, 2017, 2:07pm UTC](https://discourse.julialang.org/t/showing-function-calls-like-in-stacktrace/5307/4 "2017-08-11T14:07:29Z")

</div>

> [@wsshin](#):
>
> Is there a way to show the functions called inside a function like in the stacktrace of error messages, even if the function returns successfully?

Like `display(stacktrace())` ?
