## `prog::calltree` -- visualize the call structure of nested function calls

#### Introduction

With `prog::calltree` the call structure of nested function calls can be visualized.

#### Call(s)

`prog::calltree(statement <, maxdepth > <, excl_funcs > <, option>)`

#### Parameters

`statement` | - | a MuPAD statement to examine
`maxdepth` | - | maximal ``call depth'' to show calls on screen
`excl_funcs` | - | set of MuPAD objects to exclude from showing on screen
`option` | - | a set or one of Plain and Args

#### Options

`Args` | - | The arguments of any function call are printed additionally.
`Tree` | - | The call of `prog::calltree` returns an object of type `adt::Tree`.

#### Returns

`prog::calltree` returns the result of the execution of `statement`. Additionally, information on the flow of control is printed.

#### Related Functions

`prog::trace`, `setuserinfo`, `debug`, `prog::profile`

#### Details

- `prog::calltree` visualizes the call structure of nested function calls.
- `statement` can be any MuPAD statement. If a function is called, `prog::calltree` prints all functions called while executing `statement` in a tree structure.
- Using this output, dependencies between functions can be observed and analyzed.

#### Option: Args

- The arguments of every function call are printed.

#### Option: Tree

- The call of `prog::calltree` returns an object of type `adt::Tree`. No output is printed on screen. The return object contains all call structure informations, that would be printed on screen without this option (see `adt::Tree`).

#### Example 1

`fib` is a self-calling procedure, `prog::calltree` visualizes the calling structure:

    >> fib:= proc(n)
             begin
               if n < 2 then
                 n
               else
                 fib(n - 1) + fib(n - 2)
               end_if
             end_proc:
       prog::calltree(fib(4))

                                  fib
                                  |
                                  +-- fib
                                  |   |
                                  |   +-- fib
                                  |   |   |
                                  |   |   +-- fib
                                  |   |   |
                                  |   |   `-- fib
                                  |   |
                                  |   `-- fib
                                  |
                                  `-- fib
                                      |
                                      +-- fib
                                      |
                                      `-- fib

                                         3

With the option Args, the arguments of each function call are printed:

    >> prog::calltree(fib(3), Args)

                                fib(fib(3))
                                |
                                +-- fib(fib(2))
                                |   |
                                |   +-- fib(fib(1))
                                |   |
                                |   `-- fib(fib(0))
                                |
                                `-- fib(fib(1))

                                         2

#### Changes

- new function

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000