Msg/FunctionNestCount

From CPUlator Wiki

< Msg
Revision as of 08:29, 11 March 2019 by Henry (talk | contribs) (Created page with "A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A function is called from a caller, runs some code, and then returns to its caller. Although a function may call other functions (possibly recursively), it is unusual for the function call depth to be very large. This warning tells you that you have exceeded 32 nested function calls.

This isn't technically an error, but if this behaviour is not expected, it is likely indicative of a bug.

Debugging

  • Make sure functions are returning, not stuck in an unending recursion.
  • Make sure you do not use a call (or branch-and-link) instruction when the intention is to use a regular branch instruction.
  • Use the Call stack window (located in the same panel as the registers window) to see where the function calls are occurring. The top entry is the current PC. Each entry below that is the location of the call in the caller one nesting level up.
  • The Trace window may also be useful to see the last 200 instructions executed.

Implementation

The simulator tracks idiomatic call and return instructions and counts the function call nesting depth. This message is generated at a call instruction when the new call depth exceeds 32.

Disabling this message

This debugging check can be disabled in the Debugging Checks section of the Settings box: Function nesting too deep.